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

# MOD

> Returns the remainder of division.

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

NULL input returns NULL.

## Syntax

### Scalar

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

* This page describes the signed-integer calling form with a nonzero divisor. Equal integer types are preserved. With different signed integer types, both operands convert to the wider type in this order: TINYINT, SMALLINT, INTEGER, BIGINT.

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | TINYINT, SMALLINT, INTEGER or BIGINT | Yes | Dividend in the documented integral form. Use a nonzero divisor. Equal integer types are preserved. With different signed integer types, both operands convert to the wider type in this order: TINYINT, SMALLINT, INTEGER, BIGINT. |
| divisor | TINYINT, SMALLINT, INTEGER or BIGINT | Yes | Divisor; use a nonzero value. Use a nonzero divisor. Equal integer types are preserved. With different signed integer types, both operands convert to the wider type in this order: TINYINT, SMALLINT, INTEGER, BIGINT. |

## Returns

* Type: TINYINT, SMALLINT, INTEGER or BIGINT: the wider signed integer input type
* NULL behavior: NULL input returns NULL.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Partial (Integer results are exact within the type’s range. Mixed-type and floating-point calculations are outside this form.) |

## Usage notes

* Operands are converted to a common numeric type before calculating the remainder.
* Equal integer types are preserved. With different signed integer types, both operands convert to the wider type in this order: TINYINT, SMALLINT, INTEGER, BIGINT.
* Query tools report the divisor’s type, which can be narrower than the actual result type.
* Deterministic: The same inputs and settings produce the same result.

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT mod(-9, 4) AS "value";
```

| value |
| - |
| -1 |

### Different dividend and divisor signs

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT mod(CAST(9 AS BIGINT), CAST(-4 AS BIGINT)) AS negative_divisor, mod(CAST(-9 AS BIGINT), CAST(-4 AS BIGINT)) AS both_negative;
```

| negative\_divisor | both\_negative |
| - | - |
| 1 | -1 |

## Limitations

* Use compatible integer inputs and a nonzero divisor.


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