If you are only interested in the account and account, you can use the simple GROUP BY query above.
SELECT accountid, MAX(score)
FROM scores
GROUP BY accountid;
If you need other attributes from the rating table, you can get other attributes from the query string of the following form:
SELECT s1.*
FROM scores AS s1
LEFT OUTER JOIN scores AS s2 ON (s1.accountid = s2.accountid
AND s1.score < s2.score)
WHERE s2.accountid IS NULL;
But this still gives a few lines, in your example, where this account has two accounts corresponding to its maximum value. To further reduce the result given in one line, for example, the line with the last player, try the following:
SELECT s1.*
FROM scores AS s1
LEFT OUTER JOIN scores AS s2 ON (s1.accountid = s2.accountid
AND s1.score < s2.score)
LEFT OUTER JOIN scores AS s3 ON (s1.accountid = s3.accountid
AND s1.score = s3.score AND s1.gamedate < s3.gamedate)
WHERE s2.accountid IS NULL
AND s3.accountid IS NULL;
source
share