NULLIF

NULLIF

The NULLIF function compares two arguments expr1 and expr2. If expr1 and expr2 are equal, it returns NULL; else, it returns expr1. Unlike the other null handling function, first argument can't be NULL.

Syntax

NULLIF (expr1, expr2)
Note that first argument can be an expression that evaluates to NULL, but it can't be the literal NULL. Both the parameters are mandatory for the function to execute.
The below query returns NULL since both the input values, 12 are equal.
SELECT	NULLIF (12, 12)
FROM DUAL;
Similarly, below query return 'SUN' since both the strings are not equal.

SELECT NULLIF ('SUN', 'MOON')
FROM DUAL;
Read more: Conv. Func.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
SQL snippets
Cosmo
Sign Up Now
or Subscribe for future quizzes