# WEIGHTED_AVG

The WEIGHTED_AVG function calculates the weighted average of a numeric expression.

## Syntax

`WEIGHTED_AVG(number, weight)`

### Parameters

#### number

A numeric value that you want to calculate the weighted average for.

#### weight

A numeric value that represents the weight of the corresponding number.

## Examples

```esql
FROM employees
| STATS w_avg = WEIGHTED_AVG(salary, height) BY languages
| EVAL w_avg = ROUND(w_avg)
| KEEP w_avg, languages
| SORT languages
```

```esql
FROM sales
| STATS weighted_sales = WEIGHTED_AVG(revenue, units_sold) BY region
| EVAL weighted_sales = ROUND(weighted_sales, 2)
| KEEP weighted_sales, region
| SORT region
```
