sum.asciidoc 824 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. [discrete]
  2. [[esql-agg-sum]]
  3. === `SUM`
  4. *Syntax*
  5. [source,esql]
  6. ----
  7. SUM(expression)
  8. ----
  9. `expression`::
  10. Numeric expression.
  11. *Description*
  12. Returns the sum of a numeric expression.
  13. *Example*
  14. [source.merge.styled,esql]
  15. ----
  16. include::{esql-specs}/stats.csv-spec[tag=sum]
  17. ----
  18. [%header.monospaced.styled,format=dsv,separator=|]
  19. |===
  20. include::{esql-specs}/stats.csv-spec[tag=sum-result]
  21. |===
  22. The expression can use inline functions. For example, to calculate
  23. the sum of each employee's maximum salary changes, apply the
  24. `MV_MAX` function to each row and then sum the results:
  25. [source.merge.styled,esql]
  26. ----
  27. include::{esql-specs}/stats.csv-spec[tag=docsStatsSumNestedExpression]
  28. ----
  29. [%header.monospaced.styled,format=dsv,separator=|]
  30. |===
  31. include::{esql-specs}/stats.csv-spec[tag=docsStatsSumNestedExpression-result]
  32. |===