count.asciidoc 829 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. [discrete]
  2. [[esql-agg-count]]
  3. === `COUNT`
  4. *Syntax*
  5. [source,esql]
  6. ----
  7. COUNT([input])
  8. ----
  9. *Parameters*
  10. `input`::
  11. Column or literal for which to count the number of values. If omitted, returns a
  12. count all (the number of rows).
  13. *Description*
  14. Returns the total number (count) of input values.
  15. *Supported types*
  16. Can take any field type as input.
  17. *Examples*
  18. [source.merge.styled,esql]
  19. ----
  20. include::{esql-specs}/stats.csv-spec[tag=count]
  21. ----
  22. [%header.monospaced.styled,format=dsv,separator=|]
  23. |===
  24. include::{esql-specs}/stats.csv-spec[tag=count-result]
  25. |===
  26. To count the number of rows, use `COUNT()` or `COUNT(*)`:
  27. [source.merge.styled,esql]
  28. ----
  29. include::{esql-specs}/docs.csv-spec[tag=countAll]
  30. ----
  31. [%header.monospaced.styled,format=dsv,separator=|]
  32. |===
  33. include::{esql-specs}/docs.csv-spec[tag=countAll-result]
  34. |===