---
title: ES|QL AVG function
description: 
url: https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/aggregation-functions/avg
products:
  - Elasticsearch
---

# ES|QL AVG function
## Syntax

![Embedded](https://www.elastic.co/docs/reference/query-languages/esql/images/functions/avg.svg)


## Parameters

<definitions>
  <definition term="number">
    Expression that outputs values to average.
  </definition>
</definitions>


## Description

The average of a numeric field.

## Supported types


| number                                                                       | result |
|------------------------------------------------------------------------------|--------|
| aggregate_metric_double                                                      | double |
| double                                                                       | double |
| exponential_histogram <applies-to>Elastic Stack: Preview in 9.3</applies-to> | double |
| integer                                                                      | double |
| long                                                                         | double |
| tdigest <applies-to>Elastic Stack: Preview in 9.3</applies-to>               | double |


## Examples

```esql
FROM employees
| STATS AVG(height)
```


| AVG(height):double |
|--------------------|
| 1.7682             |

The expression can use inline functions. For example, to calculate the average over a multivalued column, first use `MV_AVG` to average the multiple values per row, and use the result with the `AVG` function
```esql
FROM employees
| STATS avg_salary_change = ROUND(AVG(MV_AVG(salary_change)), 10)
```


| avg_salary_change:double |
|--------------------------|
| 1.3904535865             |

`AVG` can also operate on `exponential_histogram` fields, computing the average of the values which were used to construct the histograms.
```esql
TS exp_histo_sample
| WHERE instance == "instance-0"
| STATS average = ROUND(AVG(responseTime), 4)
```


| average:double |
|----------------|
| 0.1666         |

`AVG` can also operate on `tdigest` and casted `histogram` fields, computing the average of the values which were used to construct the digests.
```esql
TS histogram_timeseries_index
| WHERE instance == "instance-0"
| STATS average = ROUND(AVG(responseTime::tdigest), 4)
```


| average:double |
|----------------|
| 0.1666         |