【Oracle】基本语法 - Sql对小数取整

208 阅读1分钟

ROUND

ROUND:按照指定的精度进行四舍五入
语法:round(数字,位数) || round(数字)

 select round(66.55,1) from scores   -- 结果为66.6
 select round(66.5) from scores  -- 结果为67

TRUNC

TRUNC:按照指定的精度进行截取一个数
语法:trunc(数字,位数)

select trunc(66.678,1) from scores   -- 结果为66.6

FLOOR

FLOOR:对给定的数字取整数位(向下取整)
格式:floor(数字)

 select floor(66.56) from scores  -- 结果为66

ceil

CEIL: 返回大于或等于给出数字的最小整数(向上取整)
格式:ceil(数字)

 select ceil(66.56) from scores  -- 结果为67