Skip to main content


A window function that assigns a rank to each row within the same window frame, starting with one.




RANK assigns a rank (an integer) to each row, starting with one. These ranks are determined by the values specified in the ORDER BY expression; for example, any rows that have the same value are given the same rank. However, unlike DENSE_RANK(), RANK() skips sequential numbers if two or more rows share the same rank — if two rows both have a rank of one, the next rank that will be assigned is three.

The ranks can include duplicate values if multiple rows contain the same value for the window function field.


The following example assigns a rank to each employee based on their salary within each department:

SELECT RANK() OVER (PARTITION BY Department ORDER BY Salary) FROM Company.Employee

See Also

FeedbackOpens in a new tab