日期:2014-05-18  浏览次数:20614 次

去掉小数位
select round(a.intb/c.de2,2) as dd from Dsaleson 
我以前是如上写法,是只保留了两位小数,但是结果是小数位很长,2位小数点后面全部是零,比如结果是 7.010000000000000000或者是 6.03000000000000000000, 如何让结果是7.01或者是6.03呢, 这个SQL语句怎么改呢,

------解决方案--------------------
select floor(a.intb/c.de2,2) as dd from Dsaleson
------解决方案--------------------
SQL code
select  CAST(7.010000000000000000 as decimal(10,2)),CAST(6.03000000000000000000 as decimal(10,2))
                                                                               
--------------------------------------- ---------------------------------------
                                   7.01                                    6.03

(1 行受影响)

------解决方案--------------------
SQL code
select cast(a.intb/c.de2 as decimal(10,2)) as dd from Dsaleson

------解决方案--------------------
SQL code
select cast(a.intb/c.de2 as decimal(8,2)) as dd 
from Dsaleson