Aggregate functions in ClickHouse perform calculations across multiple rows, returning a single result. They are essential for data analysis and summarization tasks.

Key features of ClickHouse aggregate functions include:

  1. Standard aggregations: Common operations like count, sum, avg, min, and max.
  2. Parametric functions: Accept additional parameters beyond columns.
  3. Combinators: Modify the behavior of aggregate functions.
  4. NULL handling: By default, NULL values are skipped during aggregation.
  5. RESPECT NULLS modifier: Available for certain functions to include NULL values.
  6. Tuple workaround: Use tuples to include NULL values in aggregations.

ClickHouse offers a wide range of aggregate functions, from basic statistical measures to advanced analytics and specialized operations. These functions enable powerful data analysis capabilities within SQL queries.

For detailed information on specific aggregate functions and their usage, explore the categories below.

Parametric Aggregate Functions

Some aggregate functions can accept not only argument columns (used for compression), but a set of parameters – constants for initialization. The syntax is two pairs of brackets instead of one. The first is for parameters, and the second is for arguments.