mv_median.asciidoc 896 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. [discrete]
  2. [[esql-mv_median]]
  3. === `MV_MEDIAN`
  4. [source,esql]
  5. ----
  6. MV_MEDIAN(v)
  7. ----
  8. *Parameters*
  9. `v`::
  10. Multivalue expression.
  11. *Description*
  12. Converts a multivalued column into a single valued column containing the median
  13. value.
  14. include::types/mv_median.asciidoc[]
  15. *Examples*
  16. [source.merge.styled,esql]
  17. ----
  18. include::{esql-specs}/math.csv-spec[tag=mv_median]
  19. ----
  20. [%header.monospaced.styled,format=dsv,separator=|]
  21. |===
  22. include::{esql-specs}/math.csv-spec[tag=mv_median-result]
  23. |===
  24. If the row has an even number of values for a column, the result will be the
  25. average of the middle two entries. If the column is not floating point, the
  26. average rounds *down*:
  27. [source.merge.styled,esql]
  28. ----
  29. include::{esql-specs}/math.csv-spec[tag=mv_median_round_down]
  30. ----
  31. [%header.monospaced.styled,format=dsv,separator=|]
  32. |===
  33. include::{esql-specs}/math.csv-spec[tag=mv_median_round_down-result]
  34. |===