您的位置:首页 > 数据库 > Oracle

oracle的round函数

2020-06-06 07:14 513 查看

round:对某个值进行四舍五入
格式:round(number,decimals)
参数:
 number:要进行四舍五入的数值
 decimals:指明需保留小数点后面的位数。可选项,忽略它则截去所有的小数部分,并四舍五入。如果为正数则表示从小数点右边开始的位置进行四舍五入,如果为负数则表示从小数点开始左边的位数,相应整数数字用0填充,小数被去掉。

案例如下

select round(1235.466) from dual;-- 返回结果为1235相当于round(1235.466,0)
select round(1235.466,2) from dual;-- 返回结果为1235.47
select round(1235.466,-1) from dual;-- 返回结果为1240
select round(1234.466,-1) from dual;-- 返回结果为1230
select round(1234.466,3) from dual;-- 返回结果为1234.466
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: