Skip to main content

Generate Rank (In Database)

Synopsis

This operator can generate the (dense) rank of each row within the given partition into a new column.

Description

The rank of a row is one plus the count of ranks before the given row. The dense rank of a row is one plus the count of distinct ranks before the given row. Note that if no partitioning is defined, the entire data set is sorted, a potentially slow operation for a large data set. For adding a unique ID variable to the data set, you may want to use your database-specific function instead, e.g. ROWNUM for Oracle.

Input

example set input

Output

example set output

Parameters

Attribute name

Name of the attribute.

Partition by

Ordered list of the partitioning attributes.

Order by

The attributes and sorting directions which should be used to determine the order of the data before the ranking is applied.

Dense rank

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