码迷,mamicode.com
首页 > 数据库 > 详细

SQL 行转列

时间:2018-12-17 14:28:25      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:student   ase   rom   group by   17.   分享   sele   数学   div   

 1 select * from Score 

技术分享图片

1 select student,
2 sum(case course when ‘语文‘ then score end) as ‘语文‘,
3 sum(case course when ‘数学‘ then score end) as ‘数学‘,
4 sum(case course when ‘英语‘ then score end) as ‘英语‘
5 from Score 
6 group by student

技术分享图片

SQL 行转列

标签:student   ase   rom   group by   17.   分享   sele   数学   div   

原文地址:https://www.cnblogs.com/flyer2018/p/10130715.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!