update case when then 的用法
Posted on 2010-01-25 14:25 Prayer 閱讀(9401) 評(píng)論(0) 編輯 收藏 引用 所屬分類: 數(shù)據(jù)庫(kù),SQL 、DB2注意要加括號(hào),在更改多個(gè)列的時(shí)候
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