描述
题目:现在运营想要找到每个学校gpa最低的同学来做调研,请你取出每个学校的最低gpa。
######################################方法一###########################################
select
up.device_id ,up1.university,up1.gpa
from(
select
university,
min(gpa) as gpa
from user_profile
group by university
) as up1
inner join user_profile up on up1.university = up.university and up1.gpa = up.gpa
order by university
######################################方法二###########################################
select device_id,university,gpa
from user_profile
where (university,gpa) in (select university,min(gpa) from user_profile group by university)
order by university