﻿---
title: ES|QL MV_MEDIAN function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/3016/reference/query-languages/esql/functions-operators/mv-functions/mv_median
products:
  - Elasticsearch
---

# ES|QL MV_MEDIAN function
## Syntax

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


## Parameters

<definitions>
  <definition term="number">
    Expression that can be null, a single value, or multiple values.
  </definition>
</definitions>


## Description

Converts a multivalued field into a single valued field containing the [median](https://en.wikipedia.org/wiki/Median) value.

## Supported types


| number        | result        |
|---------------|---------------|
| double        | double        |
| integer       | integer       |
| long          | long          |
| unsigned_long | unsigned_long |


## Examples

```esql
ROW a=[3, 5, 1]
| EVAL median_a = MV_MEDIAN(a)
```


| a:integer | median_a:integer |
|-----------|------------------|
| [3, 5, 1] | 3                |

If the row has an even number of values for a column, the result will be the average of the middle two entries. If the column is not floating point, the average rounds **down**:
```esql
ROW a=[3, 7, 1, 6]
| EVAL median_a = MV_MEDIAN(a)
```


| a:integer    | median_a:integer |
|--------------|------------------|
| [3, 7, 1, 6] | 4                |