DenseRank
Assigns a rank to each row within a partition, without gaps in the ranking when there are ties.
Category: window
Syntax:
DenseRank()
Returns: Integer
Context Filtering: ✓ Yes
Parameters
This function takes no parameters. The ranking is determined by the ORDER BY clause in the window specification.
Validation
- Minimum parameters: 0
- Maximum parameters: 0
Examples
DenseRank()
Returns the dense rank of each row based on the specified ordering. If two rows tie for rank 1, the next rank will be 2 (no gaps).
DenseRank()
When ordered by sales descending, assigns rank 1 to the highest sales, rank 2 to the next, etc. If rows 2 and 3 have the same value, both get rank 2, and the next row gets rank 3 (not 4).
Result: 1, 2, 2, 3, 4, ...
Related Functions
- Rank - Assigns rank with gaps
- PercentRank - Calculates relative rank as percentage
- RowNumber - Assigns sequential row numbers
- Ntile - Divides rows into groups
- CumeDist - Calculates cumulative distribution