Skip to main content
Scalar function
The NULL status of value selects a branch; a NULL selected branch produces NULL.

Syntax

Scalar

  • All result alternatives must have compatible types. Matching types are preserved; mixed types may be converted to a common type. Use explicit casts to choose the result type.

Arguments

Returns

  • Type: Common SQL type after conversion of not_null_value and null_value
  • NULL behavior: The NULL status of value selects a branch; a NULL selected branch produces NULL.

Properties

Usage notes

  • The first argument is tested but does not determine the type of the returned alternatives.
  • INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.
  • Query tools may report a DECIMAL result as DOUBLE or a TIME result as INTEGER. The returned value still keeps its decimal precision and scale, or its time type. A reported type does not convert the value.
  • Deterministic: The same inputs and settings produce the same result.

Examples

Typical behavior

Choose a label for a missing string

Last modified on October 15, 2026