mv_median.asciidoc 830 B

1234567891011121314151617181920212223242526
  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.merge.styled,esql]
  5. ----
  6. include::{esql-specs}/math.csv-spec[tag=mv_median]
  7. ----
  8. [%header.monospaced.styled,format=dsv,separator=|]
  9. |===
  10. include::{esql-specs}/math.csv-spec[tag=mv_median-result]
  11. |===
  12. It can be used by any numeric field type and returns a value of the same type. If the
  13. row has an even number of values for a column the result will be the average of the
  14. middle two entries. If the field is not floating point then the average rounds *down*:
  15. [source.merge.styled,esql]
  16. ----
  17. include::{esql-specs}/math.csv-spec[tag=mv_median_round_down]
  18. ----
  19. [%header.monospaced.styled,format=dsv,separator=|]
  20. |===
  21. include::{esql-specs}/math.csv-spec[tag=mv_median_round_down-result]
  22. |===