178 Rank Scores


  • 0
    J

    SET @i=0;

    SELECT scores.score,B.rank FROM
    scores
    LEFT JOIN
    (
    select A.score,@i:=@i+1 as rank
    FROM
    (SELECT DISTINCT score from scores GROUP BY score desc) A,
    (SELECT @i=0) as it
    ) B
    on scores.Score=B.score
    ORDER BY scores.score desc


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.