Most major RDBMSs support the NULLIF() operator, which returns NULL if both of its arguments are equivalent. If the arguments not equivalent, NULLIF() returns the first argument.
NULLIF() is a SQL-standard feature (it’s included in the ISO/IEC 9075 specification).