记一个简单的行列转换
有如下一张表:
要转换为:
sql语句为:
select t.name,
max(case
when t.`subject` = '语文' then t.score
end) as '语文',
max(case
when t.`subject` = '数学' then t.score
end) as '数学' ,
max(CASE
when t.`subject` = '英语' then t.score
end) as '英语'
from test01 as t
group by t.`name`;