A window function that assigns a rank to each row within the same window frame, starting with one.
DENSE_RANK() assigns a rank (an integer)
to each row, where the integers are always consecutive (unlike with
the RANK() window function).
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 RANK(), DENSE_RANK() does not skip any sequential numbers even 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 two.
DENSE_RANK() also allows duplicate values
if multiple rows contain the same value for the window function field.
The following example returns the rank of the employees based
on their salaries within each department:
SELECT DENSE_RANK() OVER (PARTITION BY Department ORDER BY Salary) FROM Company.Employee