| id | uid | score | date |
————————————————————————————————
| 1 | aaa | 10 | 2017.7.7|
| 2 | bbb | 5 | 2017.7.7|
| 3 | aaa | 15 | 2017.7.7|
| 4 | bbb | 20 | 2017.7.8|
I want to get everyone’s max score and every row should include all fields like id and date.
| id | uid | score | date |
—————————————————————————————
| 4 | bbb | 20 | 2017.7.8|
| 3 | aaa | 15 | 2017.7.7|
Select max(score) as score, id, date, uid from data group by uid order by score desc
I can use this sql to get what I want in MySQL before v5.7 but you know after MySQL 5.7 there is a sql_mode ONLY_FULL_GROUP_BY. So I can’t get the result as before. I see there are some answers tell me to disable the mode. But I want to know if there are any sql can do this as well as I don’t disable the mode.