SQL33找出每个学校GPA最低的同学

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 一看见不方便的 group 首先想到 窗口函数。
# 写的时候,一步一步写,做好检查。
select device_id,university,gpa
from
(select
device_id,
university,
gpa,
row_number() over(partition by university order by gpa ) as rk
from user_profile)
as table1
where rk=1;

# # 先写下面这个窗口,检查以下长什么样子。
# select
# university,
# gpa,
# row_number() over(partition by university order by gpa ) as rk
# from user_profile;