# MEDIAN

The MEDIAN function returns the value that is greater than half of all values and less than half of all values, also known as the 50% percentile. The result is usually approximate and may vary slightly each time due to its non-deterministic nature.

## Syntax

`MEDIAN(number)`

### Parameters

#### number

Expression that outputs the values to calculate the median of.

## Examples

Calculates both the median salary and the 50th percentile salary from the employees dataset:

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

Calculates the median of the maximum salary change for each employee:

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

## Limitations

- The MEDIAN function is usually approximate.
- MEDIAN is non-deterministic, meaning results may vary slightly even with the same data.
