日期:2014-05-18 浏览次数:20498 次
insert c(UserName,UserLl,YwMoney) select a.userName,a.UserLl,isnull(b.YwMoney,0) from a left join (select UserName,sum(YwMoney) as YwMoney from b group by UserName) b on a.UserName=b.UserName
------解决方案--------------------
select t1.userName,t1.UserLl,YwMoney=sum(YwMoney) into C from A t1 inner join B t2 on t1.userNmae=t2.userName group by t1.userName,t1.UserLl
------解决方案--------------------
insert into c select * from ( select userName,UserLl,0 as YwMoneyfrom a union all select UserName,'',sum(YwMoney) as YwMoney from b group by UserName)t
------解决方案--------------------