# MOD

`Mod` stands for Modulo. Calculates the remainder of a number divided by another number.

## Syntax

```sql
MOD (expression1 , expression2)
expression1 MOD expression2
expression1 `%` expression2

```

## Arguments

* expression1, expression2 : any numerical expression. This could be a column name, the result of another function, or a math operation.
* expression1 : dividend. A value that will be divided by expression2.
* expression2 : divisor.

## Return Type

A decimal if the input is decimal, otherwise integer.

## Remarks

Returns NULL if the divisor is 0 or either of the arguments is a NULL.

## Examples

The following queries return the remainder.

```sql
SELECT MOD (84,5);

```

```output

+------------------------------+
| mod (84,5)                   |
+------------------------------+
| 4                            |
+------------------------------+
1 row in set (899 ms)

```

```sql
SELECT 12 MOD 5;

```

```output

+------------------------------+
| 12 MOD 5                     |
+------------------------------+
| 2                            |
+------------------------------+
1 row in set (346 ms)

```

The following query returns `NULL` as the divisor is 0.

```sql
SELECT 25 % 0;

```

```output

+------------------------------+
| 25 % 0                       |
+------------------------------+
| NULL                         |
+------------------------------+
1 row in set (341 ms)

```

***

Modified at: February 23, 2023

Source: [/db/v9.1/reference/sql-reference/aggregate-functions/mod/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/aggregate-functions/mod/)

(An index of the documentation is available at /llms.txt)
