PARTITION BY
PARTITION BY divides rows into groups for separate calculations.
Rank within each department:
Each department gets its own ranking (1, 2, 3...).
This is the "Top N per group" pattern - extremely common!
Check your understanding
Rank employees by salary within their department (top earner = 1).
Examples run on the employees sample database. Open any of them in the playground to experiment.