有什么办法给数据集汇总
时间:2011-12-28
来源:互联网
如exec(@SelectResult) --这里面的列的个数是不固定的,有是会3列,有时会四列.个数是未知. 如exec(@SelectResult)这时的结果是这样 1 4.5 6 2 2.1 3 我想把上面的数据汇总一下. 结果为 1 4.5 6 2 2.1 3 3 6.6 9
作者: chirea 发布时间: 2011-12-28
作者: ssp2009 发布时间: 2011-12-28
作者: qianjin036a 发布时间: 2011-12-28
不好做,最好在@SelectResult里直接统计
比如:
@auto--自动的列,有时3个,有时四个
set @SelectResult='select a,+@auto+,c from tb'
如果是这样要怎么在@SelectResult里直接统计
作者: chirea 发布时间: 2011-12-28
create table t ( id int, num int ) insert into t select 1,5 union all select 2,6 declare @tab table ( id int, num int ) insert into @tab select * from t union all select SUM(ID),SUM(num) from t select * from @tab --drop table t
作者: ju523756055 发布时间: 2011-12-28
作者: dielianhua_chenlong 发布时间: 2011-12-28
set @SelectResult='select a,'+@auto+',c from tb union all select max(a)+1,sum(' +REPLACE(@auto,',','),sum(')+'),max(c) from tb'
作者: Monkey__D__Luffy 发布时间: 2011-12-28
lz能否在@SelectResult里直接用union all连接一下呢。。。
可以呀,可是如何汇总才是一个难点呀,因为@auto列数不固定
作者: chirea 发布时间: 2011-12-28
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28