Differences in Score Ranking Options

Hi,

Any one knows the differences between dense_rank / rank / row_number options in score ranking strategy?

1 Like

row_number () → bigint
Returns the number of the current row within its partition, counting from 1.

rank () → bigint
Returns the rank of the current row, with gaps; that is, the row_number of the first row in its peer group.

dense_rank () → bigint
Returns the rank of the current row, without gaps; this function effectively counts peer groups.

Basically it changes how ties are handled.

  • On row_number there are no ties.
  • On rank, if there are two tied at position 5, the next will be position 7 as 6 was skipped.
  • On dense_rank, if there are two tied at position 5, the next will be position 6.
3 Likes