Skip to main content

avg

Introduced in: v1.1.0 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
Query
SELECT avg(x) FROM VALUES('x Int8', 0, 1, 2, 3, 4, 5);
Response
┌─avg(x)─┐
│    2.5 │
└────────┘
Empty table returns NaN
Query
CREATE TABLE test (t UInt8) ENGINE = Memory;

SELECT avg(t) FROM test;
Response
┌─avg(x)─┐
│    nan │
└────────┘
Last modified on June 8, 2026