RANK_PERCENTILE (window)
Syntax
RANK_PERCENTILE( value [ , direction ] [ TOTAL | WITHIN ... | AMONG ... ] [ BEFORE FILTER BY ... ] )
Description
Returns the relative rank (from 0
to 1
) of the current row if ordered by the given argument. Calculated as (RANK(...) - 1) / (row count)
.
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_UNIQUE.
Argument types:
value
—Boolean | Date | Datetime | Fractional number | Integer | String | UUID
direction
—String
Return type: Fractional number
Note
Only constant values are accepted for arguments (direction
).
Examples
RANK_PERCENTILE([Profit])
RANK_PERCENTILE([Profit] TOTAL)
RANK_PERCENTILE([Profit] WITHIN [Country])
RANK_PERCENTILE([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
.