代码拉取完成,页面将自动刷新
# $618. 学生地理信息报告
# https://leetcode-cn.com/problems/students-report-by-geography/
# SQL架构
Create table If Not Exists Student (name varchar(50), continent varchar(7));
Truncate table Student;
insert into Student (name, continent) values ('Jane', 'America');
insert into Student (name, continent) values ('Pascal', 'Europe');
insert into Student (name, continent) values ('Xi', 'Asia');
insert into Student (name, continent) values ('Jack', 'America');
# Write your MySQL query statement below
select
max(
case
continent
when 'America' then name
else null
end
) as America,
max(
case
continent
when 'Asia' then name
else null
end
) as Asia,
max(
case
continent
when 'Europe' then name
else null
end
) as Europe
from
(
select
name,
continent,
row_number() over (
partition by continent
order by
name
) as rk
from
Student
) tmp
group by
rk;
# clean-up
drop table Student;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。