Reputation: 4199
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.
Upvotes: 0
Views: 187
Reputation: 47482
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
Upvotes: 0
Reputation: 8608
select user_id, max(score)
from user_scores
group by user_id
order by max(score)
Upvotes: 1
Reputation: 268
Should be something like:
SELECT UNIQUE user_id, score FROM TABLE
ORDER BY SCORE DESC
Upvotes: 0