RANK_UNIQUE (window)
Syntax
RANK_UNIQUE( 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 have different rank values. This means that rank values are sequential and different for all rows, always increasing by 1
for the next row.
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_DENSE, RANK_PERCENTILE.
Argument types:
value
—Boolean | Date | Datetime | Fractional number | Integer | String | UUID
direction
—String
Return type: Integer
Note
Only constant values are accepted for arguments (direction
).
Examples
RANK_UNIQUE([Profit])
RANK_UNIQUE([Profit] TOTAL)
RANK_UNIQUE([Profit] WITHIN [Country])
RANK_UNIQUE([Profit], "asc" 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
.