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

# TRY_DIVIDE

> Divides two numbers, returning NULL for a zero divisor.

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

Returns NULL for a NULL operand or either positive or negative zero divisor.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
try_divide(dividend, divisor)
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| dividend | TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s) | Yes | The numerator. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |
| divisor | TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s) | Yes | The denominator. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |

## Returns

* Type: DOUBLE
* Possible values: The floating-point quotient.
* NULL behavior: Returns NULL for a NULL operand or either positive or negative zero divisor.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | No |

* Approximation bound: No fixed maximum error is guaranteed.

## Usage notes

* Both operands are converted to DOUBLE before calculation.
* Floating-point overflow and NaN are ordinary floating-point results; TRY\_DIVIDE does not replace all non-finite values with NULL.
* 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.
* Exact result: Floating-point computation can round the mathematical result.

## Examples

### Value and NULL input

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT try_divide(CAST(10 AS DOUBLE), CAST(4 AS DOUBLE)) AS quotient, try_divide(CAST(10 AS DOUBLE), CAST(0 AS DOUBLE)) AS zero_divisor, try_divide(CAST(NULL AS DOUBLE), CAST(2 AS DOUBLE)) AS null_value;
```

| quotient | zero\_divisor | null\_value |
| - | - | - |
| 2.5 | NULL | NULL |

### Decimal division

The decimal inputs are converted to DOUBLE for division.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT try_divide(CAST(7.5 AS DECIMAL(8,2)), CAST(2 AS DECIMAL(8,2))) AS quotient;
```

| quotient |
| - |
| 3.75 |


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