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")
)| Parameter | Type | Required | Description |
|---|---|---|---|
when_base | T | Yes | Expression to compare against values |
value_to_match | T | Yes | Values to match against when_base (one per WHEN clause) |
result | U | Yes | Value to return, corresponding to each matching value |
default | U | Yes | Value 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
On this page