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

# ZEROIFNULL

> Returns zero for NULL input and otherwise returns the input value.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

Returns numeric zero when value is NULL.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
zeroifnull(value)
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s) | Yes | Numeric value to inspect. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |

## Returns

* Type: INTEGER for TINYINT, SMALLINT or INTEGER input; BIGINT, FLOAT or DOUBLE for the corresponding input type; DECIMAL(min(38, max(p, s+10)), s) for the effective DECIMAL(p,s) input
* NULL behavior: Returns numeric zero when value is NULL.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Partial (Choosing a common type for the input and zero can change the input type.) |

## Usage notes

* ZEROIFNULL(value) has the same effect as COALESCE(value, 0).
* The integer zero participates in choosing a compatible result type.
* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.
* The default zero is INTEGER, so TINYINT and SMALLINT inputs widen to INTEGER. For DECIMAL inputs, p and s describe the type after conversion. The result reserves at least 10 integer digits, within the 38-digit precision limit.
* With the default decimal settings used here, casting a BIGINT column to DECIMAL(38, 2) produces an effective DECIMAL(19, 2) input. Query tools can report DOUBLE even though the value keeps its decimal scale.
* Deterministic: The same inputs and settings produce the same result.

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT zeroifnull(CAST(NULL AS INT)) AS missing, zeroifnull(5) AS present;
```

| missing | present |
| - | - |
| 0 | 5 |

### Preserve a decimal value

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT zeroifnull(CAST(NULL AS DECIMAL(8,2))) AS missing, zeroifnull(CAST(2.50 AS DECIMAL(8,2))) AS present;
```

| missing | present |
| - | - |
| 0.00 | 2.50 |

## Related functions

* [coalesce](/query/sql/functions/conditional/coalesce)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.