Tied rows share rank and leave gaps.
Section: Ranking functions
RANK
sql
sql
SELECT employee_id,
department_id,
salary,
RANK() OVER (
PARTITION BY department_id
ORDER BY salary DESC
) AS salary_rank
FROM employees;Explanation
When two rows tie for rank 1, the next rank becomes 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
Split rows into quartiles with NTILE
Bucket ordered rows into four groups.
Return top values including ties
Use RANK when tied rows should all qualify.