[discrete]
[[esql-mv_median]]
=== `MV_MEDIAN`

[source,esql]
----
MV_MEDIAN(v)
----

*Parameters*

`v`::
Multivalue expression.

*Description*

Converts a multivalued column into a single valued column containing the median
value.

*Supported types*

include::types/mv_median.asciidoc[]

*Examples*

[source.merge.styled,esql]
----
include::{esql-specs}/math.csv-spec[tag=mv_median]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/math.csv-spec[tag=mv_median-result]
|===

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*:

[source.merge.styled,esql]
----
include::{esql-specs}/math.csv-spec[tag=mv_median_round_down]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/math.csv-spec[tag=mv_median_round_down-result]
|===

