EasyWindow Functions
ROW_NUMBER: number each row within a group
The query
SQL
SELECT
first_name,
last_name,
dept_id,
salary,
ROW_NUMBER() OVER (PARTITION BY dept_id ORDER BY salary DESC) AS row_num
FROM employees
ORDER BY dept_id, row_num;Note
“ROW_NUMBER assigns unique sequential integers. PARTITION BY creates groups (like GROUP BY without collapsing rows).