#SqlServer interview question: What are ranking functions?

Ranking functions return a ranking value for each row in a partition. All the ranking functions are non-deterministic. Each of the ranking functions also needs the OVER( ) clause.

The different ranking functions are as follows:

ROW_NUMBER () OVER ([ ]

<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 ([ ] <order_by_clause>)

Returns the rank of each row within the partition of a result set. After a tie there will numeric gaps in the next ranked

number.

DENSE_RANK () OVER ([ ]

<order_by_clause>)

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

NTILE (integer_expression) OVER ([ ]

<order_by_clause>)

Distributes the rows in an ordered partition into a specified number of groups.

Thanks  for reading  this  article,

Next steps :

1. Share this with your colleagues because Sharing  is Learning

       2. Comment below if you need any assistance

Powered by CodeReview – Let’s make it Better!