RANK

Returns the rank of each element in a column

RANK(column, [ascending], [rank_type])

Returns the rank of each element in column

Arguments

Argument

Description

column

Column to evaluate in ranking

[ascending]

Optional, defaults to TRUE. Order in which elements should be sorted.

  • 1: Ascending

  • 0: Descending

[rank_type]

Optional, defaults to "average". Option for how to rank the group of elements that have the same value.

  • "average": average rank of the group

  • "min": lowest rank of the group

  • "max": highest rank of the group

  • "first": rank in order of appearance

  • "dense": like "min", but rank always increases by 1 between groups

  • "percentile": returns the percentile rank for the current row

Outputs

Outputs rank of each element in column.

Example

Last updated