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
得到结果:
本文共 301 字,大约阅读时间需要 1 分钟。
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
得到结果:
转载于:https://www.cnblogs.com/lxcmyf/p/7436025.html