sql列转行查询

Posted java_pro

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql列转行查询相关的知识,希望对你有一定的参考价值。

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列转行查询的主要内容,如果未能解决你的问题,请参考以下文章