rank()

Other. 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 HAVING expressions only. This function has no arguments, and the function returns an integer.

Example

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