leecode地址链接
https://leetcode.com/problems/rank-scores/description/
Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. Note that after a tie, the next ranking number should be the next consecutive integer value. In other words, there should be no “holes” between ranks.
写一个分数排行的SQL查询语句,如果俩个分数相同,那就俩个有相同的排名,注意在这个相同的排名之后,下一个排名数应该是下一个整数值,换句话说,俩个排名支架不应该有间断。
+----+-------+
| Id | Score |
+----+-------+
| 1 | 3.50 |
| 2 | 3.65 |
| 3 | 4.00 |
| 4 | 3.85 |
| 5 | 4.00 |
| 6 | 3.65 |
+----+-------+
For example, given the above Scores table, your query should generate the following report (order by highest score):
例如,给出上面的Scores表,你的查询结果应该生成下面的结果(由高到低排序)
+-------+------+
| Score | Rank |
+-------+------+
| 4.00 | 1 |
| 4.00 | 1 |
| 3.85 | 2 |
| 3.65 | 3 |
| 3.65 | 3 |
| 3.50 | 4 |
+-------+------+
Write your MySQL query statement below
select score from Scores
order by desc
未完待续。。。