求一sql语句。在线等,立即给分

yigebendan 2008-04-14 02:24:10
数据表
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

注:最后一行为上面所有列的和
谢谢!
...全文
57 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
flairsky 2008-04-14
  • 打赏
  • 举报
回复
select * from tb
union all
select a = sum(a) , b= sum(b) , c = sum(c) from tb
kelph 2008-04-14
  • 打赏
  • 举报
回复
select * from tb 
union all
select sum(a) , sum(b) , sum(c) from tb
dawugui 2008-04-14
  • 打赏
  • 举报
回复
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 )
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 行)

*/
lxzm1001 2008-04-14
  • 打赏
  • 举报
回复
select * from tablename
union all
select sum(a),sum(b),sum(c) from tablename
昵称被占用了 2008-04-14
  • 打赏
  • 举报
回复
select a,b,c from 数据表
union all
select
sum(a) as a,
sum(b) as b,
sum(c) as c
from 数据表
dawugui 2008-04-14
  • 打赏
  • 举报
回复
select * from tb
union all
select a = sum(a) , b= sum(b) , c = sum(c) from tb

34,873

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧