Mysql-确定某字段为几位小数-FLOOR函数

135 阅读1分钟

Mysql-确定某字段为几位小数-FLOOR函数

问题:为了校验某字段为几位小数

怎么判断某个字段的小数有几位?

-- 判断该字段的小数是否只有俩位
select total_amount from r_s_d 
where r_no = 'xxxx0001' and is_delete = 0 
and total_amount * 100 - floor(total_amount*100) > 0

总结-FLOOR函数:向下取整

函数描述实例
FLOOR(x)返回小于或等于x的最大整数小于或等于 1.5 的整数:SELECT FLOOR(1.5) -- 返回1