1.行转列
select Name,
sum(case Item when ‘数学’ then score else null end) Math,
sum(case Item when ‘英语’ then score else null end) english
from table group by name
参考:sql语句实现行转列的3种方法
https://chengbo.blog.csdn.net/article/details/90404986
2.排名
select Item, name, score,
rank() over (partition by item order by score desc limit 0,2)
from table order by score desc
使用窗口函数