日期:2014-05-17 浏览次数:20476 次
UPDATE Archive_MeterInfo
SET am.IC_CardCount=tt.coutNum FROM (
select b.meterid,b.coutNum,a.IC_cardcount-b.coutNum as aa from
(select IC_cardcount,meterid from dbo.Archive_MeterInfo) a,
(select count(*) as coutNum,meterid from charge_ic where codeid_icbuytype=4 group by meterid )b
where a.meterid=b.meterid and a.IC_cardcount<>b.coutNum
)tt,
Archive_MeterInfo AS am
where tt.meterid=am.MeterID
UPDATE Archive_MeterInfo
SET IC_CardCount=tt.coutNum FROM
(select b.meterid,b.coutNum,a.IC_cardcount-b.coutNum as aa from
(select IC_cardcount,meterid from dbo.Archive_MeterInfo) a,
(select count(*) as coutNum,meterid from charge_ic where codeid_icbuytype=4 group by meterid )b
where a.meterid=b.meterid and a.IC_cardcount<>b.coutNum
)tt
where tt.meterid=Archive_MeterInfo.MeterID