Reference: https://my.oschina.net/Tsybius2014/blog/493244
A common sort of 1. Rank 1,2,3,...,n do not do special treatment for repetitive fractions
Score Rank
100 1
99 2
99 3
98 4
90 5
# Write Your MySQL query statement below Select @Counter :=@Counter+1 as rank from Scores, ( Select @Counter :=0 as CorderbyDesc ;
Sort 2. The same score is ranked the same, ranking nth indicates that there are n-1 individuals ahead, not n-1 scores.
Score Rank
100 1
99 2
99 2
98 4
90 5
# Write Your MySQL query statement below Select S1. Score, (Selectcount+1 from Scores S2where < as from ORDER by Desc
Sort 3. The same score is ranked the same, and the nth name indicates a n-1 score.
Score Rank
100 1
99 2
99 2
98 3
90 4
# Write Your MySQL query statement below Select Count (distinct t.score) Rank from Join on <= t.score #joininner join is group by S. Idorderbydesc;
Leetcode 178. Rank Scores (Database)