Aggregate functions

The following table describes the supported aggregate functions.

Function Description
avg(X) Returns the average value of all non-null X within a group.
count(*) Counts the total number of rows in the group.
count(X) Counts the number of non-null values of X in the group.
group_concat(X) Concatenates all non-null values of X into a single string, separated by commas.
group_concat(X, Y) Concatenates all non-null values of X into a single string, separated by Y.
max(X) Finds the maximum value of X in the group.
min(X) Finds the minimum value of X in the group.
string_agg(X, Y) An alias for group_concat(X, Y).
Concatenates all non-null values of X into a single string separated by Y in an arbitrary order (unless an ORDER BY clause is specified).
sum(X) Calculates the sum of all non-null values of X in the group; returns NULL if none.
total(X) Calculates the sum of all non-null values of X in the group as a floating-point number; returns 0.0 if none.