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

sql列转行查询

时间:2017-08-26 19:42:00      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:ase   src   技术分享   code   分享   ima   from   blog   语文   

test表:

技术分享

执行列转行sql:

select
    student,
    sum(case Course when 语文 then Score else null end) 语文,
    sum(case Course when 数学 then Score else null end) 数学,
    sum(case Course when 英语 then Score else null end) 英语
from 
    test 
group by 
    student

得到结果:

技术分享

 

sql列转行查询

标签:ase   src   技术分享   code   分享   ima   from   blog   语文   

原文地址:http://www.cnblogs.com/lxcmyf/p/7436025.html

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