题解 | #找出每个学校GPA最低的同学#
找出每个学校GPA最低的同学
https://www.nowcoder.com/practice/90778f5ab7d64d35a40dc1095ff79065
select device_id, university, gpa from ( select device_id,university,gpa,rank() over(partition by university order by gpa) as rk from user_profile )a where rk = 1
使用排名函数rank,按学校进行分组,组内按gpa升序排序,这样rank排名为1的就是该学校gpa最低的(若该校最低分存在多个,排名都会为1,都能取到)。开始一直报错有语法错误,多提交几次就通过了,不知道为什么。。。