rank

Description

Returns the rank within an ordered group of values.

Default ordering is in ascending time, so the first value has the lowest rank. See also dense_rank.

Return type

int64

Domain

This is a window function (calculates over a group of multiple input rows using windowing.)

Categories

Usage

rank()

Examples

make_col index:window(rank(), group_by(category_id), order_by(item_cost))

Assigns a rank to items, when ordered by cost, grouped by category. The cheapest item in each category will be given the rank 1, items with the same cost within the same category will receive the same rank.