---
schema_version: "1"
id: 69a8d51066fa86d3d45d71c81ff3e41fa623c74bb0b98e371b760ed6ba9bb7f0
title: NULLIF()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_sql/guides/bi-sql-nullif.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-sql/guide/bi-sql-nullif.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: bf4e287e5b958c6c92cc034a5a28a4dceea9f8038e9fc1ac2ef8496f1d32ee69
products:
  - SQL for Analytics Developer Guide
  - analytics
---

# 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.

```nolang
 nullif(fieldName1, fieldName2)
```

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.

```nolang
SELECT CASE WHEN City='Aberdeen'
THEN NULL
ELSE City
END AS City
FROM "Superstore"
GROUP BY City;
```

Here's how to write the same query using `nullif()`.

```nolang
SELECT NULLIF(City, 'Aberdeen') as City
FROM "Superstore"
GROUP BY City;

```

| City        |
| ----------- |
| Aberdeen    |
| Akron       |
| Albuquerque |
| Alexandria  |
