Aggregate Functions

Aggregate functions operate on values across rows to perform operations including counts, distincts, mathematical operations, and approximate cardinality estimation.

In this Topic:

List of Functions

Sub-category Function Notes
General Aggregation ANY_VALUE  
AVG  
CORR  
COUNT  
COVAR_POP  
COVAR_SAMP  
GROUPING  
GROUPING_ID Alias for GROUPING.
HASH_AGG  
LISTAGG  
MEDIAN  
MIN / MAX  
PERCENTILE_CONT  
PERCENTILE_DISC  
STDDEV Alias for STDEV_SAMP.
STDDEV_POP  
STDDEV_SAMP  
SUM  
VAR_POP  
VAR_SAMP  
VARIANCE_POP Alias for VAR_POP.
VARIANCE , VARIANCE_SAMP Aliases for VAR_SAMP.
Bitwise Aggregation BITAND_AGG  
BITOR_AGG  
BITXOR_AGG  
Semi-structured Data Aggregation ARRAY_AGG  
OBJECT_AGG  
Linear Regression REGR_AVGX  
REGR_AVGY  
REGR_COUNT  
REGR_INTERCEPT  
REGR_R2  
REGR_SLOPE  
REGR_SXX  
REGR_SXY  
REGR_SYY  
Cardinality Estimation (Using HyperLogLog) APPROX_COUNT_DISTINCT Alias for HLL.
HLL  
HLL_ACCUMULATE  
HLL_COMBINE  
HLL_ESTIMATE  
HLL_EXPORT  
HLL_IMPORT  
Similarity Estimation (Using MinHash) APPROXIMATE_JACCARD_INDEX Alias for APPROXIMATE_SIMILARITY.
APPROXIMATE_SIMILARITY  
MINHASH  
MINHASH_COMBINE  

General Usage Notes

Similar to analytic/window functions, most aggregate functions can be called with an OVER clause to perform operations over a specified group of rows (i.e. window). For more information, see Window Syntax for Aggregate Functions.