( rank + number_of_peers - 1 ) / ( total_rows )
where rank is the current row’s rank within the partition, number_of_peers is the number of row values equal to the current row value (including the current row), and total_rows is the total number of rows in the partition.
The return value ranges from 1/(total_rows) to 1.
See also PERCENT_RANK, which returns the relative rank of the current row within an ordered data set. For more information on usage, please refer to Window Functions.
Syntax
Parameters
Parameter | Description | Supported input types |
---|---|---|
<partition_by> | The expression used for the PARTITION BY clause. | Any |
<order_by> | The expression used in the ORDER BY clause. This parameter determines what value will be ranked. | Any |
Return Type
DOUBLE PRECISION
This function respects NULL
values, and results will be ordered with default null ordering NULLS LAST
unless otherwise specified in the ORDER BY
clause.