Back to course overview
SQL for Analysis
Window Functions
Rank rows within groups, compute running totals and moving averages, and measure period-over-period change, all without losing row detail.
3 lessons · 1h 57m
- 49mROW_NUMBER and RANKReading
Rank rows within groups with ROW_NUMBER, RANK and DENSE_RANK, and use the top-N-per-group pattern.
- 35mRunning totals and moving averagesReading
Turn SUM and AVG into window functions to compute running totals, shares of total and moving averages with window frames.
- 33mLAG and LEADReading
Compare each row with the previous or next one to compute month-over-month change and gaps between events.