select 分组列,
聚合函数(case 转换列 when 转换列值1then 数据列 else....end) as 列名1,
聚合函数(case 转换列 when 转换列值2then 数据列 else....end) as 列名2,
聚合函数(case 转换列 when 转换列值3then 数据列 else....end) as 列名3...from 表名
groupby 分组列;
select name,'语文' as subject,语文 as 'score' from stu_score_row_columns
union all
select name,'数学' as subject,数学 as 'score' from stu_score_row_columns
union all
select name,'英语' as subject,英语 as 'score' from stu_score_row_columns
order by name;