Window functions
Lesson 20 of 24 · SQL.Micro
Window functions compute across related rows without collapsing them. Ranking inside a group is the classic use.
ROW_NUMBER() OVER (PARTITION BY genre ORDER BY rating DESC)
PARTITION BY defines the groups; ORDER BY defines the order inside each group.
Unlike GROUP BY, every original row stays in the result.
Check yourself
How many rows does a window function remove from the result?
Show genre, title and each movie's rank inside its genre by rating (1 = best).
Do it in the browser: a real SQL tool, a short mission and instant feedback. No install.
Start this lesson — free