[discrete]
[[esql-agg-weighted-avg]]
=== `WEIGHTED_AVG`

*Syntax*

[source,esql]
----
WEIGHTED_AVG(expression, weight)
----

`expression`::
Numeric expression.

`weight`::
Numeric weight.

*Description*

The weighted average of a numeric expression.

*Supported types*

The result is always a `double` no matter the input type.

*Examples*

[source.merge.styled,esql]
----
include::{esql-specs}/stats.csv-spec[tag=weighted-avg]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/stats.csv-spec[tag=weighted-avg-result]
|===
