ClickHouse/docs/en/sql-reference/aggregate-functions/index.md
BayoNet c1b71ab06e
DOCS-733: Fixed broken links in Russian version (#13106)
* CLICKHOUSEDOCS-733: Fixed some broken links. Updated introduction and TOC in aggregate functions.

* CLICKHOUSEDOCS-733: Fixed files endings.

* CLICKHOUSEDOCS-733: Returned the list of functions back to reference index.

Co-authored-by: Sergei Shtykov <bayonet@yandex-team.ru>
Co-authored-by: emironyuk <em@don.ru>
2020-07-30 15:49:19 +03:00

1.7 KiB
Raw Blame History

toc_folder_title toc_priority toc_title
Aggregate Functions 33 Introduction

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 │
└────────┘

The sum function interprets NULL as 0. In particular, this means that if the function receives input of a selection where all the values are NULL, then the result will be 0, not NULL.

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.

Original article