count.asciidoc 611 B

123456789101112131415161718192021222324252627
  1. [discrete]
  2. [[esql-agg-count]]
  3. === `COUNT`
  4. Counts field values.
  5. [source.merge.styled,esql]
  6. ----
  7. include::{esql-specs}/stats.csv-spec[tag=count]
  8. ----
  9. [%header.monospaced.styled,format=dsv,separator=|]
  10. |===
  11. include::{esql-specs}/stats.csv-spec[tag=count-result]
  12. |===
  13. Can take any field type as input and the result is always a `long` not matter
  14. the input type.
  15. To count the number of rows, use `COUNT(*)`:
  16. [source.merge.styled,esql]
  17. ----
  18. include::{esql-specs}/docs.csv-spec[tag=countAll]
  19. ----
  20. [%header.monospaced.styled,format=dsv,separator=|]
  21. |===
  22. include::{esql-specs}/docs.csv-spec[tag=countAll-result]
  23. |===