avg
Calculates the arithmetic mean.
This page describes the RawTree engine binary used to generate this reference. It does not define Query API support. Descriptions retain upstream ClickHouse terminology. See SQL interface scope.
Calculates the arithmetic mean.
Syntax
avg(x)Arguments
Returned value
Returns the arithmetic mean, otherwise returns NaN if the input parameter x is empty. Float64
Examples
Basic usage
SELECT avg(x) FROM VALUES('x Int8', 0, 1, 2, 3, 4, 5);┌─avg(x)─┐
│ 2.5 │
└────────┘Empty table returns NaN
CREATE TABLE test (t UInt8) ENGINE = Memory;
SELECT avg(t) FROM test;┌─avg(x)─┐
│ nan │
└────────┘Introduced in version 1.1.0.