score表
id | student_id | score | date |
---|---|---|---|
1 | 1 | 80 | 20221118 |
2 | 2 | 88 | 20221118 |
3 | 1 | 78 | 20221118 |
4 | 2 | 98 | 20221118 |
5 | 3 | 89 | 20221117 |
6 | 2 | 72 | 20221117 |
7 | 1 | 63 | 20221117 |
8 | 3 | 81 | 20221117 |
7 | 1 | 67 | 20221116 |
8 | 2 | 86 | 20221116 |
求查每个 student_id 最近一次考试 分数最高的那一条数据
select * from score group by student_id having date = max(date);
这样似乎有错误
可以用窗口函数实现