Solution with using VIEW


  • 0
    U
    CREATE VIEW Temp AS
        SELECT DISTINCT Score
        FROM Scores
    ;
    
    SELECT 
        s.Score,
        (SELECT COUNT(*) FROM Temp WHERE Score >= s.Score) AS Rank
    FROM Scores AS s
    ORDER BY s.Score DESC
    ;
    
    DROP VIEW IF EXISTS Temp
    ;
    

Log in to reply
 

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