How can we assign sequential ranks to sorted employees without collapsing rows?
ROW_NUMBER() OVER (ORDER BY ...) assigns a unique incrementing integer to each row in the window.
Pagination, top-N leaderboards, assigning deterministic row indices.
SELECT
name,
salary,
ROW_NUMBER() OVER (ORDER BY salary DESC) AS salary_rank
FROM employees;Practice typing production-grade SQL code for ROW_NUMBER.