mv_median.asciidoc 790 B

1234567891011121314151617181920212223242526272829303132
  1. [[esql-mv_median]]
  2. === `MV_MEDIAN`
  3. Converts a multivalued field into a single valued field containing the median value. For example:
  4. [source,esql]
  5. ----
  6. include::{esql-specs}/math.csv-spec[tag=mv_median]
  7. ----
  8. Returns:
  9. [%header,format=dsv,separator=|]
  10. |===
  11. include::{esql-specs}/math.csv-spec[tag=mv_median-result]
  12. |===
  13. It can be used by any numeric field type and returns a value of the same type. If the
  14. row has an even number of values for a column the result will be the average of the
  15. middle two entries. If the field is not floating point then the average rounds *down*:
  16. [source,esql]
  17. ----
  18. include::{esql-specs}/math.csv-spec[tag=mv_median_round_down]
  19. ----
  20. Returns:
  21. [%header,format=dsv,separator=|]
  22. |===
  23. include::{esql-specs}/math.csv-spec[tag=mv_median_round_down-result]
  24. |===