Window functions

The following table describes the supported window functions.

Function Description
CUME_DIST Returns the cumulative distribution of a value in a partition.
DENSE_RANK Returns the rank of a row within a partition without gaps for tied values.
FIRST_VALUE Returns the first value in the window frame.
LAG Accesses the value of the preceding row in the same result set.
LAST_VALUE Returns the last value in the window frame.
LEAD Accesses the value of the following row in the same result set.
NTH_VALUE Returns the Nth value in the window frame.
NTILE Divides the result set into N approximately equal-sized buckets.
PERCENT_RANK Computes the relative rank of a row within its partition, as a percentage of the total number of rows in the partition.
RANK Returns the rank of a row within its partition, with gaps for tied values.
ROW_NUMBER Assigns a unique sequential integer to each row within a partition.

For more information, see the MySQL documentation: Window Function Descriptions.