Prayer

在一般中寻求卓越
posts - 1256, comments - 190, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

update case when then 的用法

Posted on 2010-01-25 14:25 Prayer 阅读(9352) 评论(0)  编辑 收藏 引用 所属分类: 数据库,SQLDB2

注意要加括号,在更改多个列的时候

 

ALTER      proc usp_clearActiveScoreCalcCommentScore
as
begin
update tbForum set UltimoScore=
   (case
    when AllScore-RemainScore<0 then 0
    else AllScore-RemainScore
   end),AllScore=
   (case
    when ActivityDegree>=0 and ActivityDegree<=300 then 250
    when ActivityDegree>=301 and ActivityDegree<=800 then 500
    when ActivityDegree>=801 and ActivityDegree<=2000 then 1000
    when ActivityDegree>=2001 and ActivityDegree<=4000 then 2000
    when ActivityDegree>=4001 and ActivityDegree<=8000 then 4500
    when ActivityDegree>8000 then 9000  
   end),UltimoDegree=ActivityDegree,ActivityDegree = 0
update tbForum set RemainScore=AllScore
end


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理