SELECT device_id,university,gpa
FROM (
SELECT *,ROW_NUMBER() over (PARTITION BY university ORDER BY gpa) AS rn
FROM user_profile
) AS temp
WHERE temp.rn=1
FROM (
SELECT *,ROW_NUMBER() over (PARTITION BY university ORDER BY gpa) AS rn
FROM user_profile
) AS temp
WHERE temp.rn=1