MOD
Returns the remainder of a division operation.
	Returns the remainder of a division operation.
Behavior type
ImmutableSyntax
MOD( expression1, expression2 )
Arguments
- expression1
- Resolves to a numeric data type that specifies the dividend.
- expression2
- Resolves to a numeric data type that specifies the divisor.
Computation rules
When computing MOD(expression1, expression2), the following rules apply:
- 
If either expression1orexpression2is the null value, then the result is the null value.
- 
If expression2is zero, then an exception condition is raised: data exception — division by zero.
- 
Otherwise, the result is the unique exact numeric value Rwith scale 0 (zero) such that all of the following are true:- 
Rhas the same sign asexpression2.
- 
The absolute value of Ris less than the absolute value ofexpression1.
- 
expression2=expression1*K+Rfor some exact numeric valueKwith scale 0 (zero).
 
- 
Examples
SELECT MOD(9,4);
 mod
-----
   1
(1 row)
SELECT MOD(10,3);
 mod
-----
   1
(1 row)
SELECT MOD(-10,3);
 mod
-----
  -1
(1 row)
SELECT MOD(-10,-3);
 mod
-----
  -1
(1 row)
SELECT MOD(10,-3);
 mod
-----
   1
(1 row)
=> SELECT MOD(6.2,0);
ERROR 3117:  Division by zero