median.asciidoc 832 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. [discrete]
  2. [[esql-agg-median]]
  3. === `MEDIAN`
  4. *Syntax*
  5. [source,esql]
  6. ----
  7. MEDIAN(column)
  8. ----
  9. *Parameters*
  10. `column`::
  11. Column from which to return the median value.
  12. *Description*
  13. Returns the value that is greater than half of all values and less than half of
  14. all values, also known as the 50% <<esql-agg-percentile>>.
  15. NOTE: Like <<esql-agg-percentile>>, `MEDIAN` is <<esql-agg-percentile-approximate,usually approximate>>.
  16. [WARNING]
  17. ====
  18. `MEDIAN` is also {wikipedia}/Nondeterministic_algorithm[non-deterministic].
  19. This means you can get slightly different results using the same data.
  20. ====
  21. *Example*
  22. [source.merge.styled,esql]
  23. ----
  24. include::{esql-specs}/stats_percentile.csv-spec[tag=median]
  25. ----
  26. [%header.monospaced.styled,format=dsv,separator=|]
  27. |===
  28. include::{esql-specs}/stats_percentile.csv-spec[tag=median-result]
  29. |===