1. 取四舍五入的几位小数
eg:
round(n+0.{m个0}5, m)
比如, 取两位的话:
round(15.333 + 0.005, 2)
比如, 取两位的话:
round(15.333 + 0.005, 2)
2. 只保留小数
eg:
保留两位小数,只舍
zhang@zhang>select trunc(1.2345, 2) from dual;
TRUNC(1.2345,2)
---------------
1.23
zhang@zhang>select trunc(1.2399, 2) from dual;
TRUNC(1.2399,2)
---------------
1.23
zhang@zhang>select trunc(1.2345, 2) from dual;
TRUNC(1.2345,2)
---------------
1.23
zhang@zhang>select trunc(1.2399, 2) from dual;
TRUNC(1.2399,2)
---------------
1.23
3.这个比较全了
返回大于或等于x的最大整数:
SQL> select ceil(23.33) from dual;
CEIL(23.33)
-----------
24
返回等于或小于x的最大整数:
SQL> select floor(23.33) from dual;
FLOOR(23.33)
------------
23
返回舍入到小数点右边y位的x值:rcund(x,[y])
SQL> select round(23.33) from dual;
ROUND(23.33)
------------
23
返回截尾到y位小数的x值:trunc(x,[y])
SQL> select trunc(23.33) from dual;
TRUNC(23.33)
------------
SQL> select ceil(23.33) from dual;
CEIL(23.33)
-----------
24
返回等于或小于x的最大整数:
SQL> select floor(23.33) from dual;
FLOOR(23.33)
------------
23
返回舍入到小数点右边y位的x值:rcund(x,[y])
SQL> select round(23.33) from dual;
ROUND(23.33)
------------
23
返回截尾到y位小数的x值:trunc(x,[y])
SQL> select trunc(23.33) from dual;
TRUNC(23.33)
------------
23