数据表
a   b   c
1   1   1
5   3   7
3   8   9
想得到的结果集
a   b   c
1   1   1
5   3   7
3   8   9
9   12  17注:最后一行为上面所有列的和
谢谢!

解决方案 »

  1.   

    select * from tb
    union all
    select a = sum(a) , b= sum(b) , c = sum(c) from tb
      

  2.   

    select a,b,c from 数据表
    union all 
    select
    sum(a) as a,
    sum(b) as b,
    sum(c) as c
    from 数据表
      

  3.   

    select * from tablename
    union all
    select sum(a),sum(b),sum(c) from tablename
      

  4.   

    create table tb(a int,  b int,  c int)
    insert into tb values(1 ,  1 ,  1 )
    insert into tb values(5 ,  3 ,  7 )
    insert into tb values(3 ,  8 ,  9 )
    goselect * from tb 
    union all 
    select a = sum(a) , b= sum(b) , c = sum(c) from tbdrop table tb/*
    a           b           c           
    ----------- ----------- ----------- 
    1           1           1
    5           3           7
    3           8           9
    9           12          17(所影响的行数为 4 行)*/
      

  5.   

    select * from tb 
    union all 
    select  sum(a) ,  sum(b) , sum(c) from tb
      

  6.   

    select * from tb
    union all
    select a = sum(a) , b= sum(b) , c = sum(c) from tb