Guided Notes

Window (Analytic) Functions

OVER, PARTITION BY, window frames, running totals, LAG/LEAD, and ROW_NUMBER/RANK.

Window vs. GROUP BY

Slide 1 / 5

GROUP BY collapses many rows into one per group. Window (analytic) functions also calculate over a group of rows, but return a value for every row β€” you keep the detail and add the calculation beside it.

That makes them ideal for running totals, moving averages, rankings, and comparisons with the previous row β€” all common in reporting and analytics.

← Subqueries