Window functions

GoogleSQL for BigQuery supports the followingwindow functions.

Function list

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

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.