Suppose you have the following schema (id, user_id , score). How can I take per each user the row with max score and then order all row for score. In other word I want a ranking where each user have his best result.
A:
Should be something like:
SELECT UNIQUE user_id, score FROM TABLE
ORDER BY SCORE DESC
Robert
2010-04-27 09:39:51
+1
A:
select user_id, max(score)
from user_scores
group by user_id
order by max(score)
Tommi
2010-04-27 09:39:57
A:
select @rownum := @rownum + 1 AS rank, user_id, MAX(score) as Score
from table_name t,
(SELECT @rownum := 0) r
GROUP BY user_id
ORDER BY Score
Salil
2010-04-27 09:42:30