NULLIF returns NULL when the two arguments are equivalent.

Syntax

NULLIF ( expression1, expression2 )

Arguments

  • expression: Two expressions for comparison. These expressions must be of types that can be compared to each other.
  • Use CAST or otherwise convert types when required to create the proper argument types.

Returns

NULL if the expressions are equivalent. Otherwise, returns expression1.

Examples

VALUES NULLIF (3, 3)
-- Returns NULL

VALUES NULLIF (3, 4)
-- Returns 3