muscles

Aggregate function combinators

A combinator is a suffix on the name of an aggregate function, as in sumIf. Combinators can be stacked, as in sumIfOrNull.

SuffixDescription
StateReturns the intermediate state of the aggregate as a value instead of the final result.
MergeCombines intermediate states made by the State combinator and returns the final result.
IfTakes a condition as the last argument and applies the aggregate only to the rows where it holds.
OrNullReturns NULL instead of the default value when the aggregate saw no rows.
ArrayTakes arrays and applies the aggregate to every element as if each element were a row.
ForEachTakes arrays and applies the aggregate to each position, returning an array.