Mysql按表字段分组排序,取每组数据的最值
一、需求说明
例如:有一张记录用户成绩的表 t_goal,表字段以及表数据如下:
id | uuid | goal | time |
---|---|---|---|
1 | 56a2e88e-54f4-49f6-83dd-592ce1da63bc | 90 | 2022-05-18 09:00:00 |
2 | 56a2e88e-54f4-49f6-83dd-592ce1da63bc | 92 | 2022-05-19 09:00:00 |
3 | 56a2e88e-54f4-49f6-83dd-592ce1da63bc | 88 | 2022-05-20 09:00:00 |
4 | 80be960f-cb32-4cf1-81f0-fcd5a11c92ba | 92 | 2022-05-18 09:00:00 |
5 | 80be960f-cb32-4cf1-81f0-fcd5a11c92ba | 94 | 2022-05-19 09:00:00 |
6 | 80be960f-cb32-4cf1-81f0-fcd5a11c92ba | 96 | 2022-05-20 09:00:00 |
7 | e099ba5e-27c5-4419-8bd9-7dbcb1e00cad | 86 | 2022-05-18 09:00:00 |
8 | e099ba5e-27c5-4419-8bd9-7dbcb1e00cad | 80 | 20 |