CASE_WHEN_SIMPLE
All functions > CONDITIONAL > CASE_WHEN_SIMPLE
Returns the result corresponding to the first matching value in a simple case expression
Syntax
CASE_WHEN_SIMPLE(when_base: T, values_to_match: ARRAY<T>, then: ARRAY<U>, else: U) → U
sql
Type Parameters:
T
: Any expression type (for matching)U
: Any expression type (for return values)
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
when_base | T | Yes | Expression to compare against values |
values_to_match | ARRAY<T> | Yes | Array of values to match against when_base |
then | ARRAY<U> | Yes | Array of values to return, corresponding to each match value |
else | U | Yes | Value to return if no value matches |
Returns
Same type as then values - returns the value corresponding to the first match, or else value if none match
Notes
- Compares when_base against each value in values_to_match using equality
- Returns the corresponding then value for the first match
- values_to_match and then arrays must have the same length
- All then values and else value must be of compatible types
- More concise than CASE_WHEN for simple equality comparisons