Aggregate Functions

Aggregate functions compare or combine values in a column and return a single result based on those values.

Certain restrictions apply to the use of aggregate functions with the DISTINCT clause. See DISTINCT in Aggregate Functions.

If any column in the SELECT clause is outside of an aggregate function, you must also include the column in the GROUP BY clause. See the example given for AVG.

TDV supports the aggregate functions listed in the table below.

TDV Supported Aggregate Function

Comments

ANY_VALUE

ANY_VALUE

APPROX COUNT DISTINCT

APPROX_COUNT_DISTINCT

APPROX QUANTILES

APPROX_QUANTILES

ARRAG_AGG

ARRAY_AGG

AVG

AVG.

BIT_AND

BIT_AND

BIT_OR

BIT_OR

BIT_XOR

BIT_XOR

CORR

CORR.

CORR_SPEARMAN

CORR_SPEARMAN

COUNT

COUNT.

COVAR_POP

COVAR_POP

COVAR_SAMP

COVAR_SAMP.

FIRST

FIRST

GROUP CONCAT

GROUP_CONCAT

GROUP CONCAT UNQUOTED

GROUP_CONCAT_UNQUOTED

LAST

LAST

JSON ARRAYAGG

JSON_ARRAYAGG

JSON OBJECTAGG

JSON_OBJECTAGG

LISTAGG

LISTAGGLISTAGG.

MAX

MAX

MEDIAN

MEDIAN

MIN

MIN.

NEST

NEST

NTH

NTH

PERCENTILE

PERCENTILE

PERCENTILE_APPROX

PERCENTILE_APPROX

PERCENTILE_CONT

PERCENTILE_CONT.

PERCENTILE_DISC

PERCENTILE_DISC.

QUANTILES

QUANTILES

REGR_AVGX

REGR_AVGX.

REGR_AVGY

REGR_AVGY.

REGR_COUNT

REGR_COUNT.

REGR_INTERCEPT

REGR_INTERCEPT.

REGR_R2

REGR_R2.

REGR_SLOPE

REGR_SLOPE.

REGR_SXX

REGR_SXX.

REGR_SXY

REGR_SXY.

REGR_SYY

REGR_SYY.

STDDEV

STDDEV.

STDDEV_POP

STDDEV_POP.

STDDEV_SAMP

STDDEV_SAMP.

SUM

SUM.

SUM_FLOAT

SUM_FLOAT

VARIANCE

VARIANCE.

VARIANCE_POP

VAR_POP.

VARIANCE_SAMP

VAR_SAMP.

XMLAGG

XMLAGG.