Meskipun saya tidak yakin apa artinya "bermasalah" dalam konteks ini, berikut adalah kueri yang ditulis ulang sebagai LEFT JOIN
biasa dengan subquery hanya untuk mendapatkan peringkat tepat di akhir (ORDER BY
perlu dilakukan sebelum pemeringkatan);
SELECT user_id, score, @rank := @rank + 1 AS rank FROM
(
SELECT u.user_id, u.score
FROM user_score u
LEFT JOIN user_score u2
ON u.user_id=u2.user_id
AND u.`timestamp` < u2.`timestamp`
WHERE u2.`timestamp` IS NULL
ORDER BY u.score DESC
) zz, (SELECT @rank := 0) z;
EDIT:Untuk mempertimbangkan group_id, Anda harus sedikit memperluas kueri;
SELECT user_id, score, @rank := @rank + 1 AS rank FROM
(
SELECT u.user_id, u.score
FROM user_score u
LEFT JOIN user_score u2
ON u.user_id=u2.user_id
AND u.group_id = u2.group_id -- u and u2 have the same group
AND u.`timestamp` < u2.`timestamp`
WHERE u2.`timestamp` IS NULL
AND u.group_id = 1 -- ...and that group is group 1
ORDER BY u.score DESC
) zz, (SELECT @rank := 0) z;