Data with Baraa on YouTube · Open on YouTube
Core skills: SQL depth, statistics, Python and dashboards · Advanced beginner · Lesson 17 of 99 · 57 min video, then about 9 hours of practice
Window functions: rankings, running totals and period-over-period
After this you can use ROW_NUMBER, RANK, LAG, LEAD and aggregate window functions with PARTITION BY, ORDER BY and frame clauses to answer ranking, deduplication and trend questions.
Why it matters
Window functions are the single biggest step up in analyst SQL and the most common topic in SQL interviews. Learn them by use case: top-N per group (ROW_NUMBER), deduplication (ROW_NUMBER = 1), month-over-month change (LAG), running and rolling totals (SUM OVER with a frame). The common trap is the default frame: SUM() OVER (ORDER BY date) uses RANGE, not ROWS, which gives surprising results when dates repeat.
How to use this resource
A visual explanation of PARTITION BY, ORDER BY and window frames, the three ideas everything else builds on.