--示例 insert into tb(a,b,c,d) select a.a,sum(b.b),sum(c.c),sum(d.d) from tb1 a,tb2 b,tb3 c,tb4 d where a.id = b.id and a.id = c.id and a.id = d.id group by a.a
insert into LH_SCZJ_DG(date,lh_lb,lh_fq,lh_ss) select date ,lh_lb, sum(lh_fq) as lh_fq ,sum(lh_ss) as lh_ss FROM (select * from LH_DG union all select * from [表名1] union all select * from [表名2]) t WHERE date=convert(varchar(10),getdate() - 1,120) AND lh_lb IN ('一组' , '二组','后续','液封','批量','技术调整') GROUP BY lh_lb,date
--示例
insert into tb(a,b,c,d)
select a.a,sum(b.b),sum(c.c),sum(d.d)
from tb1 a,tb2 b,tb3 c,tb4 d
where a.id = b.id and a.id = c.id and a.id = d.id
group by a.a
insert into LH_SCZJ_DG(date,lh_lb,lh_fq,lh_ss)
select date ,lh_lb, sum(lh_fq) as lh_fq ,sum(lh_ss) as lh_ss
FROM (select * from LH_DG
union all
select * from [表名1]
union all
select * from [表名2]) t
WHERE date=convert(varchar(10),getdate() - 1,120)
AND lh_lb IN ('一组' , '二组','后续','液封','批量','技术调整')
GROUP BY lh_lb,date