178. 分数排名
作者:互联网
https://leetcode-cn.com/problems/rank-scores/
178. 分数排名
select s1.Score, count(distinct s2.Score) as Rank from scores as s1, scores as s2 where s1.Score <= s2.Score group by s1.Id order by s1.Score desc;
具体思路就是把一个表变成两个表,然后进行比较
具体说一下为什么要用group by ,如果不用group by的话,原先的数据集是一个大组,只会对一行进行处理。而group by之后,是分成多个小组,然后每一个小组分别取进行处理
标签:分数,group,s2,s1,scores,Score,178,排名 来源: https://www.cnblogs.com/letlifestop/p/12486023.html