求一个计算排序值的存储过程
假设table1:username,a,b,c,d,value; 
 tagle2:logindate(日期字段),username(与table1关联)。   
 计算方法: 
       a如果不为空,value+1;b如果不为空,value+2;c如果不为空,value+3;d如果不为空,value+10 
 table2表中:如果三个月内每登录一次,value+1(其实就是计算logindate属于三个月内的记录数,但有一条:如果记录数大于5,则value+5)   
 求一个能重新计算所有记录的排序值的存储过程. 
------解决方案--------------------楼主说的逻辑不太清楚,如:   
 a、b都不为空,c、d为空,是否要加3?
------解决方案--------------------create proc dbo.Proc_update 
 as 
 begin 
      set nocount on 
      update table1 set value=value+(case when a is not null then 1 when b is not null then 2 when c is not null then 3 when d is not null then 10 else 0 end) 
      update table1 a set value=value+(case when (select count(1) from table2 where username=a.username and logindate <dateadd(mm,-3,getdate())> 5 then 5 else (select count(1) from table2 where username=a.username and logindate <dateadd(mm,-3,getdate())> 5 end) 
 end
------解决方案--------------------case when
------解决方案--------------------没说清楚