ClickHouse/docs/en/sql-reference/aggregate-functions/reference/avg.md
Roman Bug 637aacdaa4
Update docs/en/sql-reference/aggregate-functions/reference/avg.md
Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com>
2021-03-12 11:49:38 +03:00

1.0 KiB

toc_priority
5

avg

Calculates the arithmetic mean.

Syntax

avg(x)

Arguments

Returned value

  • The arithmetic mean, always as Float64.
  • NaN if the input parameter x is empty.

Example

Query:

SELECT avg(x) FROM values('x Int8', 0, 1, 2, 3, 4, 5);

Result:

┌─avg(x)─┐
│    2.5 │
└────────┘

Example

Create a temp table:

Query:

CREATE table test (t UInt8) ENGINE = Memory;

Get the arithmetic mean:

Query:

SELECT avg(t) FROM test;

Result:

┌─avg(x)─┐
│    nan │
└────────┘

Original article