Tied rows share rank without gaps.
Section: Ranking functions
DENSE_RANK
sql
sql
SELECT employee_id,
department_id,
salary,
DENSE_RANK() OVER (
PARTITION BY department_id
ORDER BY salary DESC
) AS dense_salary_rank
FROM employees;Explanation
Use `DENSE_RANK` when you want 1, 1, 2 rather than 1, 1, 3.
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