RANK_DENSE (window)
Syntax
RANK_DENSE( value [ , direction ] [ TOTAL | WITHIN ... | AMONG ... ] [ BEFORE FILTER BY ... ] )
Description
Returns the rank of the current row if ordered by the given argument. Rows corresponding to the same value used for sorting have the same rank. If the first two rows both have rank of 1
, then the next row (if it features a different value) will have rank 2
, (rank without gaps).
If direction
is "desc"
or omitted, then ranking is done from greatest to least, if "asc"
, then from least to greatest.
See also RANK, RANK_UNIQUE, RANK_PERCENTILE.
Argument types:
value
—Boolean | Date | Datetime | Number | String | UUID
direction
—String
Return type: Number (whole)
Note
Only constant values are accepted for arguments (direction
).
Examples
RANK_DENSE([Profit])
RANK_DENSE([Profit] TOTAL)
RANK_DENSE([Profit], "desc" WITHIN [Country])
RANK_DENSE([Profit] AMONG [Date])
Data source support
Materialized Dataset
, ClickHouse 1.1
, Microsoft SQL Server 2017 (14.0)
, MySQL 5.6
, Oracle Database 12c (12.1)
, PostgreSQL 9.3
.