NULLIF()
Use the nullif() function as shorthand for a searched case statement where two equal expressions return null.
nullif() takes the following syntax. Its two arguments are the expressions that you want to compare.
In this example, the query returns null for all City values that are Aberdeen. If the City value is not Aberdeen, then it returns the City value.
Here’s how to write the query as a case statement.
Here’s how to write the same query using nullif().
| City |
|---|
| Aberdeen |
| Akron |
| Albuquerque |
| Alexandria |