日期:2014-05-18 浏览次数:20622 次
update IA set ageStage2=MA.ageStage2 , ageStage4=MA.ageStage4 from (SELECT resourceID , ageStage2=max(case when ageStage=2 then quantity else 0 end) , ageStage4=max(case when ageStage=4 then quantity else 0 end) FROM #materialAge GROUP BY resourceID ) as MA,#inventoryAge as IA where MA.resourceID=IA.resourceID
------解决方案--------------------
update IA set ageStage2=(select max(case when MA.ageStage=2 then MA.quantity else 0 end) from #materialAge ), ageStage4=(select max(case when MA.ageStage=4 then MA.quantity else 0 end) from #materialAge ) from #materialAge as MA,#inventoryAge as IA where MA.resourceID=IA.resourceID