求一条查询语句
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
求一条查询语句解决办法
求一条查询语句A表:matercodematernummaterindatedepot100152007-05-075100262007-05-075B表matercodemate
