有个超市数据库会员价字段名为vip_price,
录入资料后把好多会员价精确到了分,现在想把分四舍五入
请教用语句怎么改
表名
t_bd_item_info会员价字段
vip_price例如
要把
5.66 改为5.7

解决方案 »

  1.   

    update t_bd_item_info set vip_price = cast(vip_price as decimal(18,1))
      

  2.   

    create table t_bd_item_info(vip_price decimal(18,2))
    insert into t_bd_item_info values(5.66)
    insert into t_bd_item_info values(5.65)
    insert into t_bd_item_info values(5.63)
    goupdate t_bd_item_info set vip_price = cast(vip_price as decimal(18,1))select * from t_bd_item_info
    drop table t_bd_item_info/*
    vip_price            
    -------------------- 
    5.70
    5.70
    5.60(所影响的行数为 3 行)
    */
      

  3.   

    select convert(numeric(10,1), 12.25) -- 12.3
      

  4.   

    update t_bd_item_info set vip_price = cast(vip_price as decimal(18,1))
    select convert(numeric(10,1), 12.25) -- 12.3
      

  5.   

    SELECT cast(15.578 AS DECIMAL(10,1)) aSELECT cast(15.548 AS DECIMAL(10,1)) aa
    ---------------------------------------
    15.6(1 row(s) affected)a
    ---------------------------------------
    15.5(1 row(s) affected)
      

  6.   

    --假设都是两位的小数位
    select * from tb where right(cast(col as varchar),1) <> 0
      

  7.   


    select convert(numeric(10,1), 12.27)