行转列,表1:源数据,表2:转换后的数据
select Name, sum(case Subject when '语文' then Score else 0 end) as '语文', sum(case Subject when '数学' then Score else 0 end) as '数学', sum(case Subject when '英语' then Score else 0 end) as '英语' from Test group by Name
标签:case,end,技巧,sum,when,else,Score,Sql From: https://www.cnblogs.com/friend/p/16708711.html