select
device_id,
university,
gpa
from
(select
device_id,
university,
gpa,
rank() over(PARTITION by university order by gpa) as rgpa
from
user_profile
) up
where rgpa = 1
select
device_id,
university,
gpa
from
(select
device_id,
university,
gpa,
rank() over(PARTITION by university order by gpa) as rgpa
from
user_profile
) up
where rgpa = 1