Easy solution with cases (No joins required)


  • 0
    S
    SET @count := 0;
    Select Score,
            case 
            when @prevScore = Score then @count
            when (@prevScore:=Score) is NOT NULL then @count := @count + 1
            end Rank
            from Scores, (Select @prevScore:= NULL) t
            order by Score DESC
            ;
    

Log in to reply
 

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