日期:2014-05-16 浏览次数:20949 次
select c.Part_Num, a.InCount as inCount, b.OutCount as outCount from c left join ((select part_Num,sum(inCount) as inCount from a group by part_Num)) as a on c.Part_Num=a.Part_Num left join (select part_Num,sum(outCount) as outCount from b group by part_Num) as b on b.Part_Num=a.Part_Num group by c.Part_Num
------解决方案--------------------
select Part_Num,sum(InCount),sum(OutCount) from ( select Part_Num,InCount,0 as OutCount from a union all select Part_Num,0 as InCount,OutCount from b union all select Part_Num,0,0 from c ) group by Part_Num