Aggregate Functions

Aggregate functions are essential tools in SQL that allow you to perform calculations on a set of values and return a single result.

These functions help you extract and summarize data from databases to gain valuable insights.

Function NameWhat It Does
ANYChecks if any row meets the specified condition
APPROX_COUNT_DISTINCTEstimates the number of distinct values with HyperLogLog
ARG_MAXFinds the arg value for the maximum val value
ARG_MINFinds the arg value for the minimum val value
AVG_IFCalculates the average for rows meeting a condition
ARRAY_AGGConverts all the values of a column to an Array
AVGCalculates the average value of a specific column
COUNT_DISTINCTCounts the number of distinct values in a column
COUNT_IFCounts rows meeting a specified condition
COUNTCounts the number of rows that meet certain criteria
COVAR_POPReturns the population covariance of a set of number pairs
COVAR_SAMPReturns the sample covariance of a set of number pairs
GROUP_ARRAY_MOVING_AVGReturns an array with elements calculates the moving average of input values
GROUP_ARRAY_MOVING_SUMReturns an array with elements calculates the moving sum of input values
KURTOSISCalculates the excess kurtosis of a set of values
MAX_IFFinds the maximum value for rows meeting a condition
MAXFinds the largest value in a specific column
MEDIANCalculates the median value of a specific column
MEDIAN_TDIGESTCalculates the median value of a specific column using t-digest algorithm
MIN_IFFinds the minimum value for rows meeting a condition
MINFinds the smallest value in a specific column
QUANTILE_CONTCalculates the interpolated quantile for a specific column
QUANTILE_DISCCalculates the quantile for a specific column
QUANTILE_TDIGESTCalculates the quantile using t-digest algorithm
QUANTILE_TDIGEST_WEIGHTEDCalculates the quantile with weighted using t-digest algorithm
RETENTIONCalculates retention for a set of events
SKEWNESSCalculates the skewness of a set of values
STDDEV_POPCalculates the population standard deviation of a column
STDDEV_SAMPCalculates the sample standard deviation of a column
STRING_AGGConverts all the non-NULL values to String, separated by the delimiter
SUM_IFAdds up the values meeting a condition of a specific column
SUMAdds up the values of a specific column
WINDOW_FUNNELAnalyzes user behavior in a time-ordered sequence of events

ANY

Learn how to use the ANY aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes usage and syntax details.

APPROX_COUNT_DISTINCT

Learn how to use the APPROX_COUNT_DISTINCT aggregate function in PlaidCloud Lakehouse. Estimates the number of distinct values in a data set with the...

ARG_MAX

Learn how to use the ARG_MAX aggregate function in PlaidCloud Lakehouse. Calculates the arg value for a maximum val value. Includes syntax and examples.

ARG_MIN

Learn how to use the ARG_MIN aggregate function in PlaidCloud Lakehouse. Calculates the arg value for a minimum val value. Includes syntax and examples.

ARRAY_AGG

Learn how to use the ARRAY_AGG aggregate function in PlaidCloud Lakehouse. The ARRAY_AGG function (also known by its alias LIST) transforms all the values,...

AVG

Learn how to use the AVG aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes usage and syntax details.

AVG_IF

Learn how to use the AVG_IF aggregate function in PlaidCloud Lakehouse. The suffix -If can be appended to the name of any aggregate function.

COUNT

Learn how to use the COUNT aggregate function in PlaidCloud Lakehouse. Returns the number of records returned by a SELECT query. Includes syntax and examples.

COUNT_DISTINCT

Learn how to use the COUNT_DISTINCT aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes syntax and examples.

COUNT_IF

Learn how to use the COUNT_IF aggregate function in PlaidCloud Lakehouse. The suffix _IF can be appended to the name of any aggregate function.

COVAR_POP

Learn how to use the COVAR_POP aggregate function in PlaidCloud Lakehouse. COVAR_POP returns the population covariance of a set of number pairs.

COVAR_SAMP

Learn how to use the COVAR_SAMP aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes syntax and examples.

GROUP_ARRAY_MOVING_AVG

Learn how to use the GROUP_ARRAY_MOVING_AVG aggregate function in PlaidCloud Lakehouse. The GROUP_ARRAY_MOVING_AVG function calculates the moving average of...

GROUP_ARRAY_MOVING_SUM

Learn how to use the GROUP_ARRAY_MOVING_SUM aggregate function in PlaidCloud Lakehouse. The GROUP_ARRAY_MOVING_SUM function calculates the moving sum of...

HISTOGRAM

Learn how to use the HISTOGRAM aggregate function in PlaidCloud Lakehouse. Generates a data distribution histogram using equal-height bucketing strategy.

JSON_ARRAY_AGG

Learn how to use the JSON_ARRAY_AGG aggregate function in PlaidCloud Lakehouse. Converts values into a JSON array while skipping NULLs. Includes syntax and...

JSON_OBJECT_AGG

Learn how to use the JSON_OBJECT_AGG aggregate function in PlaidCloud Lakehouse. Converts key-value pairs into a JSON object. Includes syntax and examples.

KURTOSIS

Learn how to use the KURTOSIS aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes syntax and examples.

MAX

Learn how to use the MAX aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes usage and syntax details.

MAX_IF

Learn how to use the MAX_IF aggregate function in PlaidCloud Lakehouse. The suffix _IF can be appended to the name of any aggregate function.

MEDIAN

Learn how to use the MEDIAN aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Full syntax and usage reference.

MEDIAN_TDIGEST

Learn how to use the MEDIAN_TDIGEST aggregate function in PlaidCloud Lakehouse. Computes the median of a numeric data sequence using the t-digest algorithm.

MIN

Learn how to use the MIN aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes usage and syntax details.

MIN_IF

Learn how to use the MIN_IF aggregate function in PlaidCloud Lakehouse. The suffix _IF can be appended to the name of any aggregate function.

QUANTILE_CONT

Learn how to use the QUANTILE_CONT aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes syntax and examples.

QUANTILE_DISC

Learn how to use the QUANTILE_DISC aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes syntax and examples.

QUANTILE_TDIGEST

Learn how to use the QUANTILE_TDIGEST aggregate function in PlaidCloud Lakehouse. Computes an approximate quantile of a numeric data sequence using the...

QUANTILE_TDIGEST_WEIGHTED

Learn how to use the QUANTILE_TDIGEST_WEIGHTED aggregate function in PlaidCloud Lakehouse. Computes an approximate quantile of a numeric data sequence using...

RETENTION

Learn how to use the RETENTION aggregate function in PlaidCloud Lakehouse. Aggregate function. Includes detailed syntax, examples, and usage reference.

SKEWNESS

Learn how to use the SKEWNESS aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes syntax and examples.

STDDEV_POP

Learn how to use the STDDEV_POP aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes syntax and examples.

STDDEV_SAMP

Learn how to use the STDDEV_SAMP aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes syntax and examples.

STRING_AGG

Learn how to use the STRING_AGG aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes syntax and examples.

SUM

Learn how to use the SUM aggregate function in PlaidCloud Lakehouse. Syntax, examples, and usage details. Includes usage and syntax details.

SUM_IF

Learn how to use the SUM_IF aggregate function in PlaidCloud Lakehouse. The suffix -If can be appended to the name of any aggregate function.

WINDOW_FUNNEL

Funnel Analysis