> ## 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/ifnull",
  "feedback": "Description of the issue"
}
```

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

</AgentInstructions>

> Reference material for IFNULL function

# IFNULL

Compares two expressions. Returns `<expression1>` if it’s non-NULL, otherwise returns `<expression2>`.

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
IFNULL(<expression1>, <expression2>)
```

## Parameters

| Parameter                        | Description                                                        | Supported input types |
| :------------------------------- | :----------------------------------------------------------------- | :-------------------- |
| `<expression1>`, `<expression2>` | Expressions that evaluate to any data type that Firebolt supports. | Any                   |

## Return Types

Same as input type

## Remarks

Use `ZEROIFNULL(<expression>)` as a synonym shorthand for `IFNULL(<expression>, 0)`.
`IFNULL(a, b)` has the same behaviour as `COALESCE(a, b)`.

## Example

The following truth table demonstrates values that `IFNULL` returns based on the values of two columns: `level` and `player_id`:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT level, player_id, IFNULL(level, player_id), IFNULL(player_id, level)
FROM players;
```

| level | player\_id | IFNULL(level,player\_id) | IFNULL(player\_id,level) |
| :---- | :--------- | :----------------------- | :----------------------- |
| 0     | 32         | 0                        | 32                       |
| 1     | null       | 30                       | 30                       |
| null  | 33         | 33                       | 33                       |
| null  | null       | null                     | null                     |
