# 先把学生组内排序,命名为sc,然后按照排名分组,每组按条件取值,
#这个方法特别巧妙,一开始没想到。哎,还是太菜。
with sc as (
select *, row_number() over(partition by continent order by name)rankx from student
)
select
max(if(continent= 'America',name,null))'America',
max(if(continent= 'Asia',name,null))'Asia',
max(if(continent= 'Europe',name,null))'Europe'
from sc
group by rankx
mysql 力扣,618. 学生地理信息报告
猜你喜欢
转载自blog.csdn.net/qq_42232193/article/details/106799130
今日推荐
周排行