Aggregate functions
Perform calculations across multiple rows with a single result.
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:
- Standard aggregations: Common operations like count, sum, avg, min, and max.
- Parametric functions: Accept additional parameters beyond columns.
- Combinators: Modify the behavior of aggregate functions.
- NULL handling: By default, NULL values are skipped during aggregation.
- RESPECT NULLS modifier: Available for certain functions to include NULL values.
- 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.
Basic aggregations
Perform common aggregations like count, min, max, sum, and average.
Advanced summations & averages
Perform complex summations and weighted averages.
Quantiles & percentiles
Calculate various types of quantiles and percentiles.
Array and grouping functions
Manipulate and aggregate array data types.
Bitwise and bitmap aggregations
Perform bitwise operations and bitmap aggregations.
Correlation and information theory
Calculate correlation coefficients and information theory metrics.
Graph and visualization
Generate data for graph and visualization purposes.
Combinators
Modify aggregate function behavior using suffixes.
Test error handling
Simulate errors and exceptions in aggregations.
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.