Nullif
The NULLIF function returns NULL if the two expressions are equal or the first expression if not.
Syntax
SELECT NULLIF(<expression-one>, <expresion-two>);
Example #1
SELECT NULLIF(2, 9);
| nullif |
|---|
| 2 |
Example #2
SELECT 10 / NULLIF(2, 9)
AS nullif;
| nullif |
|---|
| 5 |
Example #3
SELECT COALESCE(10 / NULLIF(0, 0), 0)
AS nullif;
| nullif |
|---|
| 0 |