Answer
RANK assigns equal rank to peer rows with the same window ordering values. • After a tie, it leaves gaps in the next rank. • The window ORDER BY defines peers. • Use DENSE_RANK when gaps are not wanted.
💡 SQL Example
SELECT name, RANK() OVER (ORDER BY salary DESC) AS salary_rank FROM employees;
Result
Ranks such as 1, 2, 2, 4
⚡ Quick Revision
RANK shares positions for ties and leaves gaps afterward.