ROUNDTRUNC

 

ROUND(n1,n2)

根据n2n1进行四舍五入,n2缺省为0,也就是对n1取整,若n2为正数,则从n1小数点右边n2位开始四舍五入;若n2为负数,则从n1小数点左边n2位开始四舍五入。

 

SQL> select round(3456.6543),round(3456.6543,2),round(3456.6543,-2) from dual;

 

ROUND(3456.6543) ROUND(3456.6543,2) ROUND(3456.6543,-2)

---------------- ------------------ -------------------

            3457            3456.65                3500

 

TRUNC(n1,n2)

TRUNCROUND类似,但是TRUNC不进行四舍五入,只进行按位截取

 

SQL> select trunc(3456.6543),trunc(3456.6543,2),trunc(3456.6543,-2) from dual;

 

TRUNC(3456.6543) TRUNC(3456.6543,2) TRUNC(3456.6543,-2)

---------------- ------------------ -------------------

            3456            3456.65                3400