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

ParameterTypeRequiredDescription
when_baseTYesExpression to compare against values
values_to_matchARRAY<T>YesArray of values to match against when_base
thenARRAY<U>YesArray of values to return, corresponding to each match value
elseUYesValue 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

Examples

Last update at: 2025/10/13 10:23:46