Solution#1
# Write your MySQL query statement belowSELECT Score, (SELECT COUNT(DISTINCT Score) FROM Scores WHERE S.Score <= Score) Rank From Scores S ORDER BY Score DESCSolution#2
# Write your MySQL query statement belowSELECT s.Score, count(distinct t.Score) RankFrom Scores s JOIN Scores t ON s.Score <= t.ScoreGROUP BY s.IdORDER BY s.Score DESC第一種方法更快 第二種方法中,必須加上GROUP BY,否則count后的結(jié)果中會(huì)有null和0;
新聞熱點(diǎn)
疑難解答
圖片精選