NULLIF#

Returns a null value if the two specified expressions are equal.

Syntax#

NULLIF ( expression , expression )

Arguments#

expression

Is any valid scalar expression.

Return types#

Returns the same type as the first expression.

NULLIF returns the first expression if the two expressions are not equal. If the expressions are equal, NULLIF returns a null value of the type of the first expression.

Example#

SELECT dept
     , NULLIF(current_year, previous_year) AS LastBudget
  FROM budgets;

See Also#