CASE WHEN VALUE

All functions > CONDITIONAL > CASE WHEN VALUE

Returns the result corresponding to the first matching value in a simple case expression

Syntax

Diagram(
    Terminal("CASE"),
    NonTerminal("when_base"),
    OneOrMore(
        Sequence(
            Terminal("WHEN"),
            NonTerminal("value_to_match"),
            Terminal("THEN"),
            NonTerminal("result")
        )
    ),
    Choice(0, Skip(),
        Sequence(Terminal("ELSE"), NonTerminal("default"))
    ),
    Terminal("END")
)
ParameterTypeRequiredDescription
when_baseTYesExpression to compare against values
value_to_matchTYesValues to match against when_base (one per WHEN clause)
resultUYesValue to return, corresponding to each matching value
defaultUYesValue to return if no value matches

Notes

  • Compares when_base against each value in WHEN clauses using equality
  • Returns the corresponding result for the first match
  • More concise than CASE WHEN for simple equality comparisons
  • All result values and default value must be of compatible types

Related Functions

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19