注意按学校升序(默认)排序
-- 子查询
SELECT a.device_id
,a.university
,a.gpa
from user_profile a
where gpa in (
select min(b.gpa)
from user_profile b
where a.university = b.university )
order by a.university
-- 子查询进阶
SELECT a.device_id
,a.university
,a.gpa
from user_profile a
where (university,gpa) in (
select b.university -- 不是纯聚合字段,需要配合group by
,min(b.gpa)
from user_profile b
group by b.university )
order by a.university
-- 使用all子查询
SELECT a.device_id
,a.university
,a.gpa
from user_profile a
where gpa <= all (
select b.gpa
from user_profile b
where a.university = b.university )
order by a.university