avg

Calculates the arithmetic mean.

Syntax

  1. avg(x)

Arguments

Returned value

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

Example

Query:

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

Result:

  1. ┌─avg(x)─┐
  2. 2.5
  3. └────────┘

Example

Create a temp table:

Query:

  1. CREATE table test (t UInt8) ENGINE = Memory;

Get the arithmetic mean:

Query:

  1. SELECT avg(t) FROM test;

Result:

  1. ┌─avg(x)─┐
  2. nan
  3. └────────┘