Oracle8i SQL Reference Release 2 (8.1.6) A76989-01 |
|
Functions, 52 of 121
MOD
returns remainder of m divided by n. Returns m if n is 0.
SELECT MOD(11,4) "Modulus" FROM DUAL; Modulus ---------- 3
This function behaves differently from the classical mathematical modulus function when m is negative. The classical modulus can be expressed using the MOD
function with this formula:
m - n * FLOOR(m/n)
The following statement illustrates the difference between the MOD
function and the classical modulus:
SELECT m, n, MOD(m, n), m - n * FLOOR(m/n) "Classical Modulus" FROM test_mod_table; M N MOD(M,N) Classical Modulus ---------- ---------- ---------- ----------------- 11 4 3 3 11 -4 3 -1 -11 4 -3 1 -11 -4 -3 -3
|
![]() Copyright © 1999 Oracle Corporation. All Rights Reserved. |
|