DENSE_RANK#
Returns the rank of rows within the partition of a result set, without any gaps in the ranking. The rank of a row is one plus the number of distinct ranks that come before the row in question.
Syntax#
DENSE_RANK ( )
OVER ( [ <partition_by_clause> ] < order_by_clause > )
Arguments#
Partitioning divides the result set produced by the FROM clause into partitions to which the DENSE_RANK function is applied. ORDER BY clause determines the order in which the DENSE_RANK function is applied to the rows in a partition.
Return types#
bigint
Example#
SELECT DENSE_RANK() OVER(PARTITION BY [IntColumn] ORDER BY [IntColumn]) AS [rank]
FROM [IntTable]