Rank Scores

  • 0

    You can define a variable to solve this problem

    SET @Rank=0;
    SELECT tableC.Score, Rank FROM Scores AS tableC LEFT JOIN (SELECT Score,@Rank:=@Rank+1 AS Rank FROM (SELECT Score FROM Scores GROUP BY Score ORDER BY Score DESC) AS tableA) AS tableB ON tableC.Score=tableB.Score ORDER BY Rank ASC;

Log in to reply

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