insert table1 select sum(aa),sum(bb),sum(cc) from table1

解决方案 »

  1.   

    select sum(aa),sum(bb),sum(cc) from table1
      

  2.   

    假如表中有一个字符字段:ee(char(10)),该如何处理??
    如:
    aa    bb     cc        ee
    1      5      6        aa 
    3      7      8        bb求和,生成一条记录:
    4      12     14      bb
      

  3.   

    insert table1 select sum(aa),sum(bb),sum(cc),MAX(ee) from table1
      

  4.   

    INSERT INTO Test1
    SELECT SUM(UserID) AS Expr1, SUM(IsSelect) AS Expr2,MAX(ee) AS Expr3
    FROM Test1
      

  5.   

    对不起 ,上面不对,是放在一个临时表Test1中去了,:(
      

  6.   

    INSERT INTO Test1
    SELECT SUM(aa) AS aa, SUM(bb) AS bb,SUM(cc) AS cc,MAX(ee) AS ee
    FROM Test1
      

  7.   

    create proc  name asdeclare @aa int,@bb int,@cc int,@ee char(10)
    select @aa=sum(isnull(aa,0)),@bb=sum(isnull(bb,0)),
           @cc=sum(isnull(cc,0)),@ee=max(ee) 
     from table1insert table1 values( @aa,@bb,@cc,@ee)