select  id,convert(decimal(12,2),sum(price)) as price from table1
group by id

解决方案 »

  1.   

    float数据类型,精度有单精度和双精度
    双精度就是精确到小数后15位,但是float是近似数,不是精确数字
    所以就出现了你现在的情况
      

  2.   

    --测试
    create table tb(id varchar(2),price float)
    insert tb values('aa',34.3)
    insert tb values('aa',12.5)
    insert tb values('bb',24.5)
    insert tb values('bb',2.4)select id,总价=convert(dec(38,2),sum(price)) from tb
    group by iddrop table tb--结果
    id   总价                                       
    ---- ---------------------------------------- 
    aa   46.80
    bb   26.90