ClickHouse/docs/en/sql-reference/aggregate-functions/index.md
2022-08-28 10:53:34 -04:00

1.4 KiB
Raw Blame History

slug sidebar_label sidebar_position
/en/sql-reference/aggregate-functions/ Aggregate Functions 33

Aggregate Functions

Aggregate functions work in the normal way as expected by database experts.

ClickHouse also supports:

NULL Processing

During aggregation, all NULLs are skipped.

Examples:

Consider this table:

┌─x─┬────y─┐
│ 1 │    2 │
│ 2 │ ᴺᵁᴸᴸ │
│ 3 │    2 │
│ 3 │    3 │
│ 3 │ ᴺᵁᴸᴸ │
└───┴──────┘

Lets 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.