Skip to main content

Window

Function NameDescription
COUNTReturns the total number of records for the specified expression.
COVAR_POPReturns the population covariance for non-NULL pairs across all input values.
COVAR_SAMPReturns the sample covariance for non-NULL pairs across all input values.
CUME_DISTReturns the cumulative distribution of the current row with regard to other values within the same window partition.
DENSE_RANKReturns the rank of the current row within its partition and ordering. Rows that are equal will have the same rank.
FIRST_VALUEReturns the first value within an ordered group of a result set.
HLLUses HyperLogLog to return an approximation of the distinct cardinality of the input.
LAGReturns the row before the current one in a partition based on the ORDER BY clause without the need for a self-join. If there are no rows, this function returns NULL.
LEADReturns the row after the current one in the same result set without the need for a self-join. If there are no rows, this function returns NULL.
MAXReturns the maximum value among the non-NULL input expressions.
MINReturns the minimum value among the non-NULL input expressions.
NDVReturns an approximate distinct value number, similar to COUNT(DISTINCT col). NDV can return results faster than using the combination of COUNT and DISTINCT while using a constant amount of memory, resulting in less memory usage for columns with high cardinality.
NTILEEqually splits the rows in each partition into ranked parts specified by the integer value and starting from 1. This function requires the ORDER BY clause.
PERCENT_RANKReturns the relative rank of the current row in the partition based on the ORDER BY clause. The displayed percentage ranges from 0.0 to 1.0.
RANKReturns the rank of the current row within its partition and placement order. Rows that are equal have the same rank. However, the count of tied rows is added to the next rank, instead of being incremented by one. The rank value starts at 1 and increases sequentially.
ROW_NUMBERReturns the row number for the current row based on the ORDER BY clause within each partition. Rows containing identical values receive different row numbers.
SUMReturns the sum of non-NULL input expressions.
VAR_POPReturns the population variance of non-NULL records.
VAR_SAMPReturns the sample variance of non-NULL records.

{{% snippet "window-function-overview-snippet.md" %}}