DENSE_RANK() OVER ...
All functions > WINDOW FUNCTION > DENSE_RANK() OVER ...
Returns the rank of the current row within its partition, without gaps. Similar to RANK but consecutive ranks have no gaps.
Syntax
Diagram(
Sequence(
Terminal("DENSE_RANK"),
Terminal("("),NonTerminal('expr'),Terminal(")"),
Terminal("OVER"),
Terminal("("),
NonTerminal("over_clause"),
Terminal(")"),
)
)| Parameter | Type | Required | Description |
|---|---|---|---|
over_clause | OVER CLAUSE | Yes | OVER (PARTITION BY ... ORDER BY ... [FRAME ...]) |
Notes
- Assigns a rank to each row within a partition
- Rows with equal ORDER BY values receive the same rank
- No gaps in ranking after ties (e.g., 1, 2, 2, 3)
- Requires ORDER BY clause to determine ranking order
- PARTITION BY creates independent ranking groups
- First row in each partition has rank 1
- Use WF_RANK for ranking with gaps after ties
- Useful when you need consecutive rank values