The NULLIF function returns a null value if the arguments are equal, otherwise it returns the value of the first argument.
NULLIF (<expression1>, <expression2>)
Description: The COALESCE and NULLIF expressions are common, shorthand forms of use for the CASE expression involving the NULL state. A COALESCE expression consists of a list of value expressions. It evaluates to the first value expression in the list that evaluates to non-NULL. If none of the value expressions in the list evaluates to non-NULL then the COALESCE expression evaluates to NULL.
The NULLIF expression consists of a list of two value expressions. If the two expressions are unequal then the NULLIF expression evaluates to the first value expression in the list. Otherwise, it evaluates to NULL.
Example: The following example demonstrates the use of CASE using the sample employee.ib database:
select NULLIF(department, head_dept) from department