mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 17:44:23 +00:00
884 B
884 B
toc_priority |
---|
5 |
avg
Calculates the arithmetic mean.
Syntax
avgWeighted(x)
Parameter
x
— Values.
x
must be
Integer,
floating-point, or
Decimal.
Returned value
0
if the supplied parameter is empty.- Mean otherwise.
Return type is always Float64.
Example
Query:
SELECT avg(x) FROM values('x Int8', 0, 1, 2, 3, 4, 5)
Result:
┌─avg(x)─┐
│ 2.5 │
└────────┘
Example
Query:
CREATE table test (t UInt8) ENGINE = Memory;
SELECT avg(t) FROM test
Result:
┌─avg(x)─┐
│ 0 │
└────────┘