34,873
社区成员
发帖
与我相关
我的任务
分享select * from tb
union all
select sum(a) , sum(b) , sum(c) from tbcreate 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 )
go
select * from tb
union all
select a = sum(a) , b= sum(b) , c = sum(c) from tb
drop table tb
/*
a b c
----------- ----------- -----------
1 1 1
5 3 7
3 8 9
9 12 17
(所影响的行数为 4 行)
*/select a,b,c from 数据表
union all
select
sum(a) as a,
sum(b) as b,
sum(c) as c
from 数据表