RANKBY
Ranks values within a column, partitioned by the unique values of a separate column
Last updated
Ranks values within a column, partitioned by the unique values of a separate column
Last updated
RANKBY(column
, partition
, [ascending]
, [rank_type]
)
Ranks the values within a column
when grouped by unique values within a partition column
RANKBY() is a window function, which perfoms like RANK() except partitioned by the values of a separate column
Argument
Description
column
Column to evaluate in ranking
partition column
Column containing unique values.
[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
"dense": like "min", but rank always increases by 1 between groups
Outputs column of values containing rank of each value