Sunday, April 13, 2014

What are Ranking Functions?

Ranking functions return a ranking value for each row in a partition. All the ranking functions are non-deterministic. Different Ranking functions are:

ROWJNUMBER () OVER ([<partition_by_clause>] <order_by_clause>)

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

RANK () OVER ([<partition_by_clause>] <order_by_clause>)

Returns the rank of each row within the partition of a result set.

DENSE_RANK () OVER ([<partition_by_clause>] <order_by_clause>)

Returns the rank of rows within the partition of a result set, without any gaps in the ranking.

No comments:

Post a Comment