# MEDIAN

The `MEDIAN` function calculates the value that is greater than half of all values and less than half of all values, also known as the 50th percentile. The result is usually approximate.

## Syntax

`MEDIAN(number)`

### Parameters

#### `number`

The input numeric value for which the median is calculated.

## Examples

Calculating the median and 50th percentile of salaries

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

Calculating the median of maximum values in a multivalued column

To calculate the median of the maximum values of a multivalued column, first use `MV_MAX` to get the maximum value per row, and then use the result with the `MEDIAN` function:

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

## Limitations

- The `MEDIAN` function is non-deterministic, meaning you may get slightly different results when using the same data.
- Like the `PERCENTILE` function, the `MEDIAN` function provides approximate results.
