case 可不可以用在update语句中呀.
我想把 工资大于1000的增加19%,大于2000的增5%,大于3000的增加2%
用一个update 语句来更新.
大家给点例子.谢谢.

解决方案 »

  1.   

    可以:update 工资表
    set 工资=case when 工资>3000 then 工资*1.02 
             when 工资>2000 then 工资*1.05
             when 工资>1000 then 工资*1.19
             else 工资
         end
      

  2.   

    update 表 set 工资=case when 工资>=1000 and 工资<2000 then 工资*1.19 
                      case when 工资>=2000 and 工资<3000 then 工资*1.05
                      case when 工资>=3000 then 工资*1.02 end