CASE WHEN
All functions > CONDITIONAL > CASE WHEN
Returns the result of the first condition that evaluates to true
Syntax
Diagram(
Terminal("CASE"),
OneOrMore(
Sequence(
Terminal("WHEN"),
NonTerminal("condition"),
Terminal("THEN"),
NonTerminal("result")
)
),
Choice(0, Skip(),
Sequence(Terminal("ELSE"), NonTerminal("default"))
),
Terminal("END")
)| Parameter | Type | Required | Description |
|---|---|---|---|
condition | BOOLEAN | Yes | Boolean conditions to evaluate in order |
result | T | Yes | Value to return, corresponding to each when condition |
default | T | No | Value to return if no condition is true (optional) |
Notes
- Evaluates conditions in order and returns the first matching result
- If no condition matches and else is not provided, returns NULL
- Short-circuits: stops evaluating once a condition is true
- All then values and else value must be of compatible types
Related Functions
On this page