with t as (select*, rank()over( partition by university order by gpa ) as gpa_m from user_profile) select device_id,university,gpa from t where gpa_m=1 order by university;