So I have 3 columns; name (VARCHAR), score (INT), submit\_date (DATE).
Users with the same name can have multiple entries in the table.

I got close with:

```sql
SELECT name, Max(score) as maxScore, Max(submit_date) as submitDate 
FROM score_table 
GROUP BY name 
ORDER BY maxScore DESC 
LIMIT 10

```

The problem is this query only compares scores so even though a later submission date could have a lower score, it compares the higher score which is no longer interesting.

I need to somehow filter the table to only compare the latest submit\_dates for each name and then order it by score.

Like

```sql
SELECT name, Max(score) as maxScore, Max(submit_date) as submitDate 
FROM score_table
WHERE submit_date = the_latest_submit_date_for_that_user??
GROUP BY name
ORDER BY Max(score)
LIMIT 10

```

EDIT: Adding example data and expected result

```
name  score  submit_date
------------------------
user1   4     2020-01-01
user1   1     2020-08-18
user2   2     2020-08-18
user3   3     2020-08-18

```

If I submit the query I highlighted first above with LIMIT 2 I would get user1 with score 4 and user3 with score 3. What I want to happen is get user3 with score 3 and user2 with score 2 since user1 has a later submission that has a score of 1 and I only want to compare the latest submit\_date for each user.