03-oracle数值函数

--round(数值,想要保留的位数如1.2.3),作用:保留小数取值时四舍五入
select round(678.656) 不保留小数,
round(678.456,1) 保留一位小数,
round(678.456,2) 保留两位小数,
round(678.456,-1) 整数进位个位四舍五入,
round(678.456,-2) 整数进位十位四舍五入
from dual;

--trunc(数值,想要截取的位数如1.2.3),作用:保留小数截取时不四舍五入
select trunc(678.446,1) 截取保留1位,
trunc(678.446,2) 截取保留2位,
trunc(678.446,-1) 截取整数至个位不四舍五入,
trunc(648.446,-2) 截取整数至十位不四舍五入
from dual;

--mod(数值,除数),取模(即求余数)
select mod(10,3) 十除以3的余数,
mod(5,3) 五除以3的余数
from dual;

原文地址:https://www.cnblogs.com/joeshang/p/10680067.html