[]
This function calculates the percentage of the relative rank of a row within a partition of rows. To compute the percentage, use the rank of the row and the number of the total rows as rank-1 / rows -1, and the range will be [0,1].
To sort the rows, this function needs ORDERBY. The tied rows are identified by the combined values of the ORDERBY fields. If ORDERBY is not used, all rows are tied and return 0. It does not accept window frame definitions, such as FRAMEROWS and FRAMERANGE. It includes NULL values by default and treats them as the lowest possible values.
W_PERCENTRANK()
//WINDOW(W_PERCENTRANK(), ORDERBY([sold]))
city | sold | percent_rank | rank-1
--------------------------------------------------------------
Paris 100 0 0
Berlin 150 0.25 1
Moscow 200 0.5 2
Rome 200 0.5 2
London 300 1 4
// WINDOW(W_PERCENTRANK(), ORDERBY([sold], [city]))
city | sold | percent_rank | rank-1
--------------------------------------------------------
Paris 100 0 0
Berlin 150 0.25 1
Moscow 200 0.5 2
Rome 200 0.75 3
London 300 1 4