Advanced Analytics · 9 min read · Beginner
Window Functions (RANK, ROW_NUMBER & OVER)
Rank learners per track and calculate running totals without collapsing rows using SQL Window Functions.
What you'll learn
- Understand how OVER (PARTITION BY ... ORDER BY ...) differs from GROUP BY
- Assign per-category rankings using RANK() and ROW_NUMBER()
GROUP BY collapses many rows into one summary row per group. Window Functions (OVER (...)) compute rankings or running totals while keeping every individual row intact!
Fill-in-the-Blank Exercise
Rank Learners Within Each Track
Rank learners by highest score inside each track partition.
SELECT name, track, score,
RANK() ( BY track ORDER BY score DESC) AS track_rank
FROM enrollments;Try It Yourself
SQLPer-Track Leaderboard with RANK()
Query Result (In-Browser SQLite)
Click Run SQL to execute this query against a live in-browser SQLite database.
Check Your Understanding
Score: 0 / 1
1. How does a window function (OVER) differ from GROUP BY?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.