Suppose salaries are:
100 100 90 80
Results:
ROW_NUMBER: 1 2 3 4 RANK: 1 1 3 4 DENSE_RANK: 1 1 2 3
ROW_NUMBER
Every row gets a unique number.
RANK
Ties receive the same rank, and gaps are created.
DENSE_RANK
Ties receive the same rank, but no gaps.
SQL · Window Functions
What is the difference between ROW_NUMBER, RANK, and DENSE_RANK?
Suppose salaries are:
100 100 90 80
Results:
ROW_NUMBER: 1 2 3 4 RANK: 1 1 3 4 DENSE_RANK: 1 1 2 3
Every row gets a unique number.
Ties receive the same rank, and gaps are created.
Ties receive the same rank, but no gaps.
🎯 Put this concept into practice
Solidify this answer with real hands-on interview drills in the browser studio.