MySQL Window Functions
11 functions
ROW_NUMBERROW_NUMBER() OVER (w)Assigns a unique sequential integer to each row within a partition.
RANKRANK() OVER (w)Assigns the same rank to equal values, with gaps in ranking.
DENSE_RANKDENSE_RANK() OVER (w)Assigns the same rank to equal values, without gaps in ranking.
PERCENT_RANKPERCENT_RANK() OVER (w)Returns the relative rank of a row as a value between 0 and 1.
CUME_DISTCUME_DIST() OVER (w)Returns the cumulative distribution value.
NTILENTILE(n) OVER (w)Divides the partition into n equal buckets.
LAGLAG(expr, n, default) OVER (w)Returns the value from n rows before the current row.
LEADLEAD(expr, n, default) OVER (w)Returns the value from n rows after the current row.
FIRST_VALUEFIRST_VALUE(expr) OVER (w)Returns the first value in the window frame.
LAST_VALUELAST_VALUE(expr) OVER (w)Returns the last value in the window frame.
NTH_VALUENTH_VALUE(expr, n) OVER (w)Returns the nth value in the window frame.
