解决方案 »

  1.   

    多张表join起来再就和咯,最起码你要提供“多张表”是什么表,有哪些相关的列还有表之间的关系吧?不然怎么写?
      

  2.   


    --示例
    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
      

  3.   


    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
      

  4.   

    将多个表查询合并成一个表,再用sum求和咯。