04 August 2010

Using Ranking Functions

  • Ranking functions return a ranking value for each row in a partition.
  • Depending on the function that is used, some rows might receive the same value as other rows.
  • Ranking functions are nondeterministic.
SQL Server 2005 has total of 4 ranking function.

1.ROW_NUMBER () OVER ()
Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition.

2.RANK () OVER ()
Returns the rank of each row within the partition of a result set.

3.DENSE_RANK () OVER ()
Returns the rank of rows within the partition of a result set, without any gaps in the ranking.

4.NTILE (integer_expression) OVER ()
Distributes the rows in an ordered partition into a specified number of groups


No comments:

Post a Comment

Your comments, Feedbacks and Suggestions are very much valuable to me :)

Things are upgraded

My Dear readers, I am really thankful for being supportive all these years. This site was the first blog site I ever created in my life...