rank
Ranks the current row within its partition with gaps. In other words, if the value of any row it encounters is equal to the value of a previous row then it will receive the same rank as that previous row. The rank of the next row is then equal to the rank of the previous row plus a gap equal to the number of times the previous rank was given.
The dense_rank function provides the same behaviour but without gaps in ranking.
Syntax
For more detail on window function syntax see: Window Functions - Syntax.
Returned value
- A number for the current row within its partition, including gaps. UInt64.
Example
The following example is based on the example provided in the video instructional Ranking window functions in ClickHouse.
Query:
Result: