Skip to main content
Skip to main content

avg

avg

Introduced in: v1.1

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