有一个字段是保存数据num1.223999999999999
1.223434343254354
1.223000000000001我要怎么写让他变成
num
1.224
1.223
1.223我的写法是select round(num,3) from 表发现还是什么都没变,数字还是1.223999999999999,没有变成1.224

解决方案 »

  1.   

    create table tb(num float)
    insert into tb select 
    1.223999999999999 union all select
    1.223434343254354 union all select
    1.223000000000001
    goselect CONVERT(decimal(18,3),num) from tb
    drop table tb/*
    ---------------------------------------
    1.224
    1.223
    1.223(3 行受影响)*/
      

  2.   


    cast(1.123123131 as decimal(18,3))cast(1.123123131 as numeric(18,3))
      

  3.   

    CONVERT(DEC(18,3),1.123123131 )
      

  4.   

    convert(dec(18,3),1.123123131 )cast(1.123123131 as decimal(18,3))