可以代替很多游标做的事情。

select  str_userid,(sum(case
when (sort<>'MT21' and sort<>'MT22' and sort<>'MS54' and sort<>'MP56')then

   (case
    when (Isnull(M1,0)/ration)>1.5 then (1.5* Isnull(str_scale,1))
    else (Isnull(M1,0)/ration)* Isnull(str_scale,1)
   end)
else ((Isnull(M1,0)/ration)* Isnull(str_scale,1))
end)
/sum(str_scale))
as m01
from Tongj_VIEW_Menology_Strong
where ration<>0 and ration is not null and year_month='2006'
group by str_userid
order by m01 desc
Posted on 2006-03-03 10:07  Blue  阅读(225)  评论(0)    收藏  举报