Hackerrank MySQL
Window functions compute across related rows without collapsing them. ROW_NUMBER() OVER (ORDER BY marks DESC) ranks students but keeps every row. GROUP BY would squash them.
MySQL 8+: ROW_NUMBER, RANK, DENSE_RANK, SUM() OVER (PARTITION BY city). PARTITION BY is ‘GROUP BY that doesn’t hide rows’.
Trap — window functions on 5.7. Trap: using GROUP BY when you still needed each student row plus a rank.
On the example next to this theory — LEAD And LAG — wHERE combines predicates with AND/OR; LIKE does pattern match.
On the example next to this theory: Ranking Functions: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
On the example next to this theory: Hackerrank MySQL: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
ROW_NUMBER() OVER (ORDER BY marks DESC) AS rank