In a nutshell
NULLIF function compares two expressions and returns
NULL if they’re both equal or the first expression they aren’t equal. You can use
NULLIF to handle special cases where you might want to return
NULL if two values match.
SELECT NULLIF(column1, 0) as result FROM my_table;
NULLIF will compare the value of
0 for every table row. If they are equal,
NULL is returned. Otherwise,
column1 is returned.