rank()

Returns the position of the row in the current group (only used in GROUP HAVING expression).

Syntax

rank()

Usage

Returns the position of the row in the current group, starting from position 0. This function is useful only in a GROUP FILTER expression. This function has no arguments, and the function returns an integer.

Example

rank() > 3 returns 0 for the first four rows in a group and 1 for all other rows.