题解 | #找出每个学校GPA最低的同学#
找出每个学校GPA最低的同学
http://www.nowcoder.com/practice/90778f5ab7d64d35a40dc1095ff79065
使用窗口函数,先分组(按university)也就是partition by university,分组后每组的gpa升序,命名为rk,那么每组的最小值就是排在第一位的值,即需rk=1就可以得到每组的最小值; SELECT device_id, university, gpa FROM (select device_id, university, gpa, row_number() over (partition by university order by gpa) rk from user_profile) as a where rk = 1