> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for NULLIF function

# NULLIF

The `NULLIF` function compares the values of its parameters and returns `NULL` if they are equal. Otherwise, it returns the value of its first parameter.
Therefore, `NULLIF` performs the inverse operation of the [COALESCE](/reference-sql/functions-reference/conditional-and-miscellaneous/coalesce) function.

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
NULLIF(<expression1>, <expression2>)
```

## Parameters

| Parameter       | Description                                                              | Supported input types |
| :-------------- | :----------------------------------------------------------------------- | :-------------------- |
| `<expression1>` | Expression of any type that is comparable to the type of `<expression2>` | Any                   |
| `<expression2>` | Expression of any type that is comparable to the type of `<expression1>` | Any                   |

If `<expression1>` and `<expression2>` have different types, they will be promoted to their least common supertype for the purpose of comparison. The same type promotion rules as for the regular comparison operators (e.g. `=`) apply.

## Return Types

If `<expression1>` and `<expression2>` have the same type, this will also be the return type of the `NULLIF` function.
If `<expression1>` and `<expression2>` have different types, the return type will be the least common supertype to which they are promoted for comparison purposes.

## Examples

This example below highlights an instance where `NULL` would be returned from `NULLIF`:

<div className="query-window">
  ```
  SELECT NULLIF('(none)', '(none)');
  ```

  | nullif <span>text null</span> |
  | :---------------------------- |
  | NULL                          |

  <p><span>Rows: 1</span><span>Execution time: 4.99ms</span></p>
</div>

In the next example, `NULLIF` returns the value of `<expression1>` because it is not equal to the value of `<expression2>`:

<div className="query-window">
  ```
  SELECT NULLIF('Level 4', '(none)');
  ```

  | nullif <span>text null</span> |
  | :---------------------------- |
  | Level 4                       |

  <p><span>Rows: 1</span><span>Execution time: 6.26ms</span></p>
</div>

The following example illustrates type promotion if the parameters to `NULLIF` have different types. The least common supertype of `REAL` and `BIGINT` is `DOUBLE`:

<div className="query-window">
  ```
  SELECT NULLIF(3.14::REAL, 42::BIGINT);
  ```

  | nullif <span>double null</span> |
  | :------------------------------ |
  | 3.140000104904175               |

  <p><span>Rows: 1</span><span>Execution time: 7.99ms</span></p>
</div>
