[]
This function returns the rank of each row within the partition of a result set. Peers are considered as ties and receive the same rank.
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 1. 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_RANK()
// WINDOW(W_RANK(), ORDERBY([sold]))
city | sold | rank
----------------------------------------------
Paris 100 1
Berlin 150 2
Rome 200 3
Moscow 200 3
London 300 5
// WINDOW(W_RANK(), ORDERBY([sold], [city]))
city | sold | rank
----------------------------------------------
Paris 100 1
Berlin 150 2
Rome 200 3
Moscow 200 4
London 300 5