> ## 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.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/functions-reference/conditional-and-miscellaneous/nullif",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> 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":"github-light","dark":"github-dark"}}
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.

## Example

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

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
NULLIF('(none)', '(none)')
```

**Returns**: The `TEXT` value `NULL`

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

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
NULLIF('Level 4', '(none)')
```

**Returns**: The `TEXT` value `'Level 4'`

Finally, the following example illustrates type promotion if the parameters to `NULLIF` have different types:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
NULLIF(3.14::REAL, 42::BIGINT)
```

**Returns**: The `DOUBLE` value `3.14`, since the least common supertype of `REAL` and `BIGINT` is `DOUBLE`.
