ClickHouse/docs/en/sql-reference/aggregate-functions/reference/avgweighted.md
Ivan Blinkov 7170f3c534
[docs] split aggregate function and system table references (#11742)
* prefer relative links from root

* wip

* split aggregate function reference

* split system tables
2020-06-18 11:24:31 +03:00

999 B

toc_priority
107

avgWeighted

Calculates the weighted arithmetic mean.

Syntax

avgWeighted(x, weight)

Parameters

Type of x and weight must be the same.

Returned value

  • Weighted mean.
  • NaN. If all the weights are equal to 0.

Type: Float64.

Example

Query:

SELECT avgWeighted(x, w)
FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2))

Result:

┌─avgWeighted(x, weight)─┐
│                      8 │
└────────────────────────┘