Unit 5: Window functions: ranking, running totals and comparing rows

Calculate across related rows — rank them, compare each with the one before, keep running totals — without losing the individual rows the way GROUP BY does.

The big picture

Window functions are the single most tested "advanced" SQL topic. Top N per group, month-on-month growth, running totals, streaks — all of them become short once you think in windows: for each row, look at a set of related rows, and work something out.

Lessons in this unit