Window functions

GoogleSQL for BigQuery supports the following window functions.

Function list

Name Summary
CUME_DIST Gets the cumulative distribution (relative position (0,1]) of each row within a window.
For more information, see Numbering functions.
DENSE_RANK Gets the dense rank (1-based, no gaps) of each row within a window.
For more information, see Numbering functions.
FIRST_VALUE Gets a value for the first row in the current window frame.
For more information, see Navigation functions.
LAG Gets a value for a preceding row.
For more information, see Navigation functions.
LAST_VALUE Gets a value for the last row in the current window frame.
For more information, see Navigation functions.
LEAD Gets a value for a subsequent row.
For more information, see Navigation functions.
NTH_VALUE Gets a value for the Nth row of the current window frame.
For more information, see Navigation functions.
NTILE Gets the quantile bucket number (1-based) of each row within a window.
For more information, see Numbering functions.
PERCENT_RANK Gets the percentile rank (from 0 to 1) of each row within a window.
For more information, see Numbering functions.
PERCENTILE_CONT Computes the specified percentile for a value, using linear interpolation.
For more information, see Navigation functions.
PERCENTILE_DISC Computes the specified percentile for a discrete value.
For more information, see Navigation functions.
RANK Gets the rank (1-based) of each row within a window.
For more information, see Numbering functions.
ROW_NUMBER Gets the sequential row number (1-based) of each row within a window.
For more information, see Numbering functions.
ST_CLUSTERDBSCAN Performs DBSCAN clustering on a group of GEOGRAPHY values and produces a 0-based cluster number for this row.
For more information, see Geography functions.