Categories:
Numeric Functions (Rounding and Truncation)

MOD

Returns the remainder of input expr1 divided by input expr2.

Equivalent to the modulo arithmetic operator (e.g. expr1 % expr2).

Syntax

MOD( <expr1> , <expr2> )

Arguments

expr1
A numeric expression.
expr2
A numeric expression.

Returns

Returns either an integer or a fixed-point decimal number.

Usage Notes

  • Both expr1 and expr2 must be numeric expressions. They are not required to be integers.

Examples

The following example shows usage of the MOD() function on both integer and non-integer values:

SELECT MOD(3, 2) AS mod1, MOD(4.5, 1.2) AS mod2;

Output:

+------+------+
| MOD1 | MOD2 |
+------+------+
|    1 |  0.9 |
+------+------+