SQL Server编程求解!!!!!

自由心证 2001-11-28 07:00:44
有这样一张表:
id times price
1 111 111
2 222 222
3 333 333
... ... ...
要求编程或写存储过程,在同一个记录集中输入下面格式
id times price
1 111 111
2 222 222
3 333 333
... ... ...
总计 666 666(这里的值是假设只有3行数据)
我怎么都做不道出现在同一个记录集中
...全文
28 1 打赏 收藏 举报
写回复
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
昵称被占用了 2001-11-28
  • 打赏
  • 举报
回复
select convert(char(10),id) as id,times,price
from TableName
union
select '总计' as id,sum(times) as times,sum(price) as price
from TableName

发帖
MS-SQL Server

3.4w+

社区成员

MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
帖子事件
创建了帖子
2001-11-28 07:00
社区公告
暂无公告