sql 178. Rank Scores(1st).sql

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 178. Rank Scores(1st).sql相关的知识,希望对你有一定的参考价值。

# Write your MySQL query statement below

SELECT A.Score, (SELECT COUNT(DISTINCT(B.Score)) FROM Scores AS B WHERE B.Score >= A.Score) AS Rank
FROM Scores AS A
ORDER BY A.Score DESC
SELECT
  Score,
  @rank := @rank + (@prev <> (@prev := Score)) Rank
FROM
  Scores,
  (SELECT @rank := 0, @prev := -1) a
ORDER BY Score desc

以上是关于sql 178. Rank Scores(1st).sql的主要内容,如果未能解决你的问题,请参考以下文章

sql 178. Rank Scores(1st).sql

sql 178. Rank Scores(1st).sql

sql 178. Rank Scores(1st).sql

sql 178. Rank Scores(1st).sql

sql -leetcode 178. Rank Scores

178. Rank Scores (Medium)