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

# PMOD

> Returns the remainder adjusted using ((value % divisor) + divisor) % divisor.

<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"}}
pmod(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

* INTEGER inputs return INTEGER values, even when query tools report a wider type.
* Equal integer types are preserved. With different signed integer types, both operands convert to the wider type in this order: TINYINT, SMALLINT, INTEGER, BIGINT.
* Integer inputs return their common signed integer type, even when query tools report DOUBLE.
* Deterministic: The same inputs and settings produce the same result.

## Examples

### Typical behavior

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

| value |
| - |
| 3 |

### Different dividend and divisor signs

With a negative divisor, the adjusted remainder can be negative.

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

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

## Limitations

* Use compatible integer inputs and a nonzero divisor.
* A positive divisor produces a nonnegative result. A negative divisor may produce a negative result.


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