Oracle Remainder函数与Mod函数的区别

REMAINDER returns the remainder of the 1st argument divided by the 2nd argument.

Remainder is similar to MOD except thaqt REMAINDER uses ROUND in its calculations, whereas MOD uses FLOOR
在用round(n1,n2)和mod(n1,n2)函数在进行运算时,都用了一个公式result=n2-(n1*N);N=n2/n1;
而在remainder(n1,n2)函数中,N=round(n2/n1),在mod(n1,n2)函数中N=floor(n2/n1);
例如:

SQL> select remainder(3.5,2) from dual;

REMAINDER(3.5,2)
----------------
-.5

SQL> select mod(3.5,2) from dual;

MOD(3.5,2)
----------

你可能感兴趣的:(oracle,sql)