Oracle® TimesTen In-Memory Database SQL Reference Release 11.2.1 Part Number E13070-03 |
|
|
View PDF |
Returns the remainder of an INTEGER expression divided by a second INTEGER expression.
SQL syntax
MOD(Expression1, Expression2)
Parameters
MOD has the following parameters:
Parameter | Description |
---|---|
Expression1 |
An INTEGER expression. |
Expression2 |
An INTEGER expression. |
Description
MOD returns the remainder of Expression1
divided by Expression2
.
If Expression2
is 0, then MOD returns Expression1
.
If either Expression1
or Expression2
is NULL, MOD returns NULL.
MOD is treated as a binary arithmetic operation, so the return type is determined according to the rules specified in Chapter 1, "Data Types".
The MOD function behaves differently from the classic mathematical modulus function when one of the operands is negative. The following table illustrates this difference:
M | N | Classic Modulus | MOD(M,N) |
---|---|---|---|
11 | 3 | 2 | 2 |
11 | -3 | -1 | 2 |
-11 | 3 | 1 | -2 |
-11 | -3 | -2 | -2 |
The following example tests if the value of the expression m
is divisible by the value of expression n
.
SELECT m, n FROM test WHERE MOD(m, n) = 0;