RANK, DENSE_RANK, ROW_NUMBER

Published July 26, 2025 By Sai Sree Ram Gundepudi

Ranking Functions

These assign ranks or row numbers within partitions.

ROW_NUMBER

SELECT first_name, salary,
       ROW_NUMBER() OVER (ORDER BY salary DESC) AS rank
FROM employees;

RANK

Gaps are introduced in ranking.

DENSE_RANK

No gaps in ranking.

Was this solution helpful?

Your feedback helps improve our technical knowledge repository.

Share this article