Unique sequence with no ties.
Section: Ranking functions
ROW_NUMBER
sql
sql
SELECT employee_id,
department_id,
salary,
ROW_NUMBER() OVER (
PARTITION BY department_id
ORDER BY salary DESC
) AS rn
FROM employees;Explanation
`ROW_NUMBER` always assigns distinct numbers, even when sort values tie.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Ranking functions