17,377
社区成员
发帖
与我相关
我的任务
分享
select a.rq,a.bm,a.a1+b.a1 a,a.b1+b.b1 b
from 表1 a,表2 b
where a.rq=b.rq and a.bm=b.bm
union all
select a.rq,0,sum(a) a,sum(b) b
from
(select a.rq,a.bm,a.a1+b.a1 a,a.b1+b.b1 b
from 表1 a,表2 b
where a.rq=b.rq and a.bm=b.bm)t group by a.rq;
insert into table
select a+b,'0',rq from (select (A.a1+B.a2) as a,(A.b1+B.b2) as b,rq
from 表1 A,表2 B
where A.rq=B.rq and A.bm=B.bm);
insert into table
select a+b,'0' from (select (A.a1+B.a2) as a,(A.b1+B.b2) as b
from 表1 A,表2 B
where A.rq=B.rq and A.bm=B.bm);