Slow solution but easy to understand


  • 0
    X

    Rank = the number of scores that are greater than the current selected score (inclusive)

    SELECT s1.Score, 
    (SELECT COUNT(DISTINCT(s2.Score)) FROM Scores s2 WHERE s2.Score >= s1.Score) AS Rank
    FROM Scores s1
    ORDER BY s1.Score DESC;
    

Log in to reply
 

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