NullIf SQL Function

The nullif() function returns its first argument if the arguments are different, and will return NULL if the arguments are the same. If written in english language, it can be written as Null if first argument is same as second argument.

        SELECT NUllIf('A','A') /* returns NULL since A is equals to A */;
        

SELECT NUllIf('A','B') /* returns A since A is not equals to B */;

SELECT NUllIf(NULL,'B') /* returns NULL since NULL is not equals to B */;

SELECT NUllIf('A',NULL) /* returns A since A is not equals to NULL */;

Can be used in aggregate functions, when logic is required to use column value or not. e.g. SELECT SUM( NullIf(OrderAmount , 9.95) ) .... not to include orders in total when it's 9.95.