Wednesday, January 20, 2010

Ranking functions - part 2

In part 1 we have seen the ROW_NUMBER and RANK functions so let's start see the other functions.
DENSE_RANK: it similar to RANK but If you do not want any gaps in a sequence, you can use the DENSE_RANK function. DENSE_RANK assigns the same value to each duplicate but does not produce gaps in the sequence.
Let's see an example:



NTILE: is used to divide a result set into approximately equal groups. Let's see this example to understand this function:



The result set divided into 3 groups so NTILE function allows you to divide a result set into approximately equal-sized groups.

No comments: