## MEDIAN

The `MEDIAN` function in ES|QL returns the value that is greater than half of all values and less than half of all values, also known as the 50% PERCENTILE. Like `PERCENTILE`, `MEDIAN` is usually approximate and is also non-deterministic. This means you can get slightly different results using the same data.

### Examples

Here are a couple of examples of how to use the `MEDIAN` function in ES|QL:

```esql
FROM employees
| STATS MEDIAN(salary), PERCENTILE(salary, 50)
```

In this example, the `MEDIAN` function is used to calculate the median salary from the `employees` data stream or index.

```esql
FROM employees
| STATS median_max_salary_change = MEDIAN(MV_MAX(salary_change))
```

In this example, the `MEDIAN` function is used in conjunction with the `MV_MAX` function to calculate the median of the maximum values of a multivalued column `salary_change`.