Module lessons (2/4)
Window Functions: Rankings and Group Calculations
ROW_NUMBER, RANK, and DENSE_RANK with OVER (PARTITION BY ...) without collapsing rows.
What you'll learn in this lesson
- Distinguish
GROUP BY(collapses rows) from window functionsOVER (...)(keep each row intact). - Calculate rankings within each partition with
ROW_NUMBER,RANKandDENSE_RANK, mastering the management of ties. - Filter the top-N by group by combining a CTE outside the calculation window.
Overview
GROUP BY compresses one hundred lines into one summary line per group. But what do you do when you want to keep all the individual rows (names, prices, timestamps) alongside each one with its ranking in the category or the percentage of the total? Window Functions (OVER) are needed.
Window functions are evaluated after WHERE, GROUP BY and HAVING, but before the final ORDER BY.
Sections covered in this lesson
- 11. Mental Model:
GROUP BYvsOVER (...)and Equal Merit - 22. Progressive & Annotated Examples
- 33. Interactive Lab: Compare
ROW_NUMBER,RANKandDENSE_RANK - 44. Diagnostic Verification (Quiz)
- 55. Progressive Practical Laboratory
Unlock "Window Functions: Rankings and Group Calculations" and the full SQL Course curriculum
ROW_NUMBER, RANK, and DENSE_RANK with OVER (PARTITION BY ...) without collapsing rows.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in SQL Course plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.