Linux中名字由横的变成竖的,竖表转横表

insertintotestselect'2006级期末考','20080101','张三','语文','101'insertintotestselect'2006级期末考','20080202','李四','语文','109'insertintotestselect'2006级期末考','20080303','王五','语文','100'insertintotestselect'2006级期末考','20080101','张三','数学','101'insertintotestselect'2006级期末考','20080202','李四','数学','85'insertintotestselect'2006级期末考','20080303','王五','数学','58'insertintotestselect'2006级期末考','20080101','张三','政治','56'insertintotestselect'2006级期末考','20080202','李四','政治','56'insertintotestselect'2006级期末考','20080303','王五','政治','50'insertintotestselect'2006级期末考','20080101','张三','英语','102'insertintotestselect'2006级期末考','20080202','李四','英语','110'insertintotestselect'2006级期末考','20080303','王五','英语','93'go--测试declare@sqlvarchar(8000)set@sql='select A1,A2,A3'select@sql=@sql+',sum(case when A4='''+A4+'''then A5 else 0 end)['+A4+']'from(selectdistinctA4fromtest)aset@sql=@sql+'from test group by A1,A2,A3 order by A1,A2,A3'exec(@sql)--删除测试环境droptabletestsetnocountoff/*--

A1 A2 A3 数学 英语 语文 政治

-------------------- -------------------- -------------------- ---------------------- ---------------------- ---------------------- ----------------------

2006级期末考 20080101 张三 101 102 101 56

2006级期末考 20080202 李四 85 110 109 56

2006级期末考 20080303 王五 58 93 100 50*/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值