## Syntax
```mermaid
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> DENSE_RANK[DENSE_RANK]:::quoted
DENSE_RANK --> End((END))
```
## Purpose
The `DENSE_RANK` SQL function assigns a ranking number to each row based on the value of an expression. Separate ranking sequences can be introduced by partitioning on a key.
Rows with the same value receive the same rank. The next different value receives the next consecutive rank, without leaving gaps. Rankings are calculated within each partition when a partition is specified.
See also [[ROW_NUMBER]] for numbering rows and [[RANK]] for ranking while leaving gaps in the ranking for duplicate values.
Parameters:
- Current value expression (`ANY`): the expression whose values are to be ranked.
- Partition key (`varchar2`): the partition key.
Returns: the dense rank as `int32`.
## Examples
The following example retrieves the dense rank for each value without partitioning:
```sql
select c
, dense_rank(c, null)
from csvtable
( passing 'a,a,b,c'
row delimiter ','
column delimiter '#'
columns c varchar2 position next
)
-------------------
a 1
a 1
b 2
c 3
```
The following example retrieves the dense rank per partitioned group:
```sql
select c
, grp
, dense_rank(c, grp)
from csvtable
( passing 'a#GRP1,a#GRP1,a#GRP2,b#GRP1,c#GRP1,c#GRP2'
row delimiter ','
column delimiter '#'
columns c varchar2 position next
, grp varchar2 position next
)
-------------------
a GRP1 1
a GRP1 1
a GRP2 1
b GRP1 2
c GRP1 3
c GRP2 2
```