Aggregate Functions
Aggregate functions work in the normal way as expected by database experts.
ClickHouse also supports:
- Parametric aggregate functions, which accept other parameters in addition to columns.
- Combinators, which change the behavior of aggregate functions.
NULL Processing
During aggregation, all NULL
s are skipped.
Examples:
Consider this table:
┌─x─┬────y─┐
│ 1 │ 2 │
│ 2 │ ᴺᵁᴸᴸ │
│ 3 │ 2 │
│ 3 │ 3 │
│ 3 │ ᴺᵁᴸᴸ │
└───┴──────┘
Let’s say you need to total the values in the y
column:
SELECT sum(y) FROM t_null_big
┌─sum(y)─┐
│ 7 │
└────────┘
Now you can use the groupArray
function to create an array from the y
column:
SELECT groupArray(y) FROM t_null_big
┌─groupArray(y)─┐
│ [2,2,3] │
└───────────────┘
groupArray
does not include NULL
in the resulting array.
当前内容版权归 ClickHouse 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ClickHouse .