- 分數相同名次相同
SELECT a.rank AS 'Rank', ID,SCORE FROM (SELECT ID,SCORE, @prev := @curr, @curr := SCORE, @rank := IF(@prev = @curr, @rank, @rank + 1) AS rank FROM user_data, (SELECT @curr := null, @prev := null, @rank := 0) s where THEDATE ='2018-05-10' ORDER BY SCORE DESC limit 10) a;
輸出結果: