求一条查询语句
A表:
matercode maternum materindate depot
1001 5 2007-05-07 5
1002 6 2007-05-07 5
B表
matercode maternum materindate depot
1001 6 2007-05-07 5
如何使查询结果为
matercode maternum materindate depot
1001 11 2007-05-07 5
1002 6 2007-05-07 5
也就是说.相同的matercode中的maternum要加在一起.
------解决方案----------------------try
select matercode,sum(maternum) as maternum,materindate,depot
from
(
select * from A
union all
select * from B
)as tmp
group by matercode,materindate,depot