Window Functions
Window functions applies aggregate and ranking functions over a particular window (set of rows).
RANK
The RANK()
function assigns a rank to every row within a partition of a result set.
For each partition, the rank of the first row is 1. The RANK()
function adds the number of tied rows to the tied rank to calculate the rank of the next row, so the ranks may not be sequential. In addition, rows with the same values will get the same rank.
Correct RANK
usage
ROW_NUMBER
The ROW_NUMBER()
function is a window function that assigns a sequential integer to each row in a result set.
Correct ROW_NUMBER
usage
DENSE_RANK
The DENSE_RANK()
assigns a rank to every row in each partition of a result set. Different from the RANK()
function, the DENSE_RANK()
function always returns consecutive rank values.
For each partition, the DENSE_RANK()
function returns the same rank for the rows which have the same values
Correct DENSE_RANK
usage
NTILE
Currently not supported, Blocking Issue