SQL动态行列变换
来源:互联网 发布:淘宝网短裙 编辑:程序博客网 时间:2024/05/26 19:16
DECLARE @sql varchar(8000)
SELECT @sql=isnull(@sql+',','')+'max(case cname when '''+cname+''' then '''+degree+''' else 0 end) ['+cname+']' //动态行列变换
from(
select * from (select * from (select a.stuid,a.classid,a.id,a.degree,a.cid,c.cname from (select b.stuid,a.classid,a.id,b.degree,a.cid from T_couser a left join sc b on a.id=b.cid) a left join course c on a.cid=c.cid)
a, T_stu b where a.stuid=b.sid) a where a.classid='001' or a.sid='001' or a.sname='001'
) AS a
SET @sql='select sid as 学号,sname as 姓名,'+@sql+' from '
exec(@sql)
SELECT @sql=isnull(@sql+',','')+'max(case cname when '''+cname+''' then '''+degree+''' else 0 end) ['+cname+']' //动态行列变换
from(
select * from (select * from (select a.stuid,a.classid,a.id,a.degree,a.cid,c.cname from (select b.stuid,a.classid,a.id,b.degree,a.cid from T_couser a left join sc b on a.id=b.cid) a left join course c on a.cid=c.cid)
a, T_stu b where a.stuid=b.sid) a where a.classid='001' or a.sid='001' or a.sname='001'
) AS a
SET @sql='select sid as 学号,sname as 姓名,'+@sql+' from '
exec(@sql)
1 0
- SQL动态行列变换
- SQL报表之行列变换
- SQL动态行列倒转
- 行列变换、PL/SQL游标加锁
- 行列转化(动态sql)
- 行列变换
- 行列变换
- Sql 行列转换 动态Sql(Pivot)
- 动态SQL的使用例子, 行列转换.
- 动态SQL的使用例子, 行列转换.
- 动态生成SQL语句-行列转置
- 行列转换-->动态SQL语句例子
- sql行列转换例子(动态)
- 数组的行列变换
- PostgreSQL行列变换
- Matlab矩阵行列变换
- SQL 2008行列转换的pivot--产生动态列
- 简化实现动态行列转置的SQL
- c++ virtual的作用
- TCP与UDP区别
- js exploit
- 蓝桥杯 欧拉和鸡蛋
- 安卓问题集锦
- SQL动态行列变换
- 数据库必备
- C++ MD5字符串加密
- linux设置ls显示的各种文件颜色
- MC9S12G ADC配置
- cf #344 div2 -C. Report
- LintCode-打劫房屋
- Eclipse常用快捷键
- Objective-C 和 Core Foundation 对象相互转换的内存管理总结