我试图首先让用户获得每个级别的最高分,然后将每个分数相加以找到用户的总体高分。
+-----------+----------+----------+--------------------+
| id | name | score | level_id |
+-----------+----------+----------+--------------------+
| 1 | Jane Doe | 100 | 1 |
| 2 | Jane Doe | 50 | 2 |
| 1 | John Doe | 100 | 1 |
| 2 | John Doe | 50 | 2 |
+-----------+----------+----------+--------------------+
我已经设法找到用户在所有级别的最高分,但是我怎样才能为每个级别做到这一点
select user_id, id, max(correct_answers)
from score
group by user_id