ORACLE round 与 trunc 的区别


今早在看论坛时突然想起这两个函数,所以就记录下来,以后好参考一下

首先看一下例子:

Windows XP

orcle 9.2.0.1.0

Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as SCOTT

SQL> select ROUND(12375.989,-2) FROM DUAL;

ROUND(12375.989,-2)
-------------------
              12400

SQL> select ROUND(12335.989,-2) FROM DUAL;

ROUND(12335.989,-2)
-------------------
              12300

SQL> select TRUNC(123875.989,-2) FROM DUAL;

TRUNC(123875.989,-2)
--------------------
              123800
1. 这两个函数都都有两个参数,如果没有写后面的数字那么默认是0.

2.round(xx,number)是要四舍五入的.

3.trunc(xx,number)是不具有四舍五入的功能

posted on   dhj  阅读(147)  评论(0编辑  收藏  举报

努力加载评论中...

导航

点击右上角即可分享
微信分享提示