Sorry, currently the Judger does not support multiple statements in SQL query. Please limit your query to a single query statement.
finally accepted solution after limiting the query to a single query statement.
SELECT Score, CASE WHEN @prev = Score THEN @rank # print @rank when @prev equals the Score WHEN @prev := Score THEN @rank := @rank + 1 # don't print anything, just used for the value assignment WHEN @rank := @rank + 1 THEN @rank # same reason as above, in case the first WHEN statement was not executed at the beginning END AS Rank FROM Scores, (SELECT @rank := 0, @prev := NULL) r ORDER BY Score DESC
@ngly, I have now explained how it works in the comment
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.