case.asciidoc 866 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. [discrete]
  2. [[esql-case]]
  3. === `CASE`
  4. *Syntax*
  5. [source,esql]
  6. ----
  7. CASE(condition1, value1[, ..., conditionN, valueN][, default_value])
  8. ----
  9. *Parameters*
  10. `conditionX`::
  11. A condition.
  12. `valueX`::
  13. The value that's returned when the corresponding condition is the first to
  14. evaluate to `true`.
  15. `default_value`::
  16. The default value that's is returned when no condition matches.
  17. *Description*
  18. Accepts pairs of conditions and values. The function returns the value that
  19. belongs to the first condition that evaluates to `true`.
  20. If the number of arguments is odd, the last argument is the default value which
  21. is returned when no condition matches.
  22. *Example*
  23. [source,esql]
  24. [source.merge.styled,esql]
  25. ----
  26. include::{esql-specs}/docs.csv-spec[tag=case]
  27. ----
  28. [%header.monospaced.styled,format=dsv,separator=|]
  29. |===
  30. include::{esql-specs}/docs.csv-spec[tag=case-result]
  31. |===