2020-04-03 13:23:32 +00:00
---
2022-04-03 23:05:35 +00:00
toc_folder_title: Aggregate Functions
toc_priority: 33
toc_title: Introduction
2020-04-03 13:23:32 +00:00
---
2022-04-03 23:05:35 +00:00
# Aggregate Functions {#aggregate-functions}
2017-12-28 15:13:23 +00:00
Aggregate functions work in the [normal ](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial ) way as expected by database experts.
ClickHouse also supports:
2020-06-18 08:24:31 +00:00
- [Parametric aggregate functions ](../../sql-reference/aggregate-functions/parametric-functions.md#aggregate_functions_parametric ), which accept other parameters in addition to columns.
- [Combinators ](../../sql-reference/aggregate-functions/combinators.md#aggregate_functions_combinators ), which change the behavior of aggregate functions.
2018-03-25 02:04:22 +00:00
2020-07-30 12:49:19 +00:00
2020-04-30 18:19:18 +00:00
## NULL Processing {#null-processing}
2018-09-04 11:18:59 +00:00
During aggregation, all `NULL` s are skipped.
**Examples:**
Consider this table:
2020-03-20 10:10:48 +00:00
``` text
2018-09-04 11:18:59 +00:00
┌─x─┬────y─┐
│ 1 │ 2 │
│ 2 │ ᴺᵁᴸᴸ │
│ 3 │ 2 │
│ 3 │ 3 │
│ 3 │ ᴺᵁᴸᴸ │
└───┴──────┘
```
2020-03-20 10:10:48 +00:00
Let’ s say you need to total the values in the `y` column:
2018-09-04 11:18:59 +00:00
2020-03-20 10:10:48 +00:00
``` sql
2019-09-23 15:31:46 +00:00
SELECT sum(y) FROM t_null_big
```
2020-03-20 10:10:48 +00:00
2020-07-30 12:49:19 +00:00
```text
┌─sum(y)─┐
│ 7 │
└────────┘
```
2018-09-04 11:18:59 +00:00
Now you can use the `groupArray` function to create an array from the `y` column:
2020-03-20 10:10:48 +00:00
``` sql
2019-09-23 15:31:46 +00:00
SELECT groupArray(y) FROM t_null_big
2018-09-04 11:18:59 +00:00
```
2020-03-20 10:10:48 +00:00
``` text
2018-09-04 11:18:59 +00:00
┌─groupArray(y)─┐
│ [2,2,3] │
└───────────────┘
```
`groupArray` does not include `NULL` in the resulting array.
2020-07-30 12:49:19 +00:00