1.查詢當前分數的排名,一般是查詢大於等於當前分數的記錄總數,題目限制名次之間不應該有“間隔”
,所以需要去重。然後根據這個記錄總數去降序排序
select Score
,(
select count(distinct Score)
from Scores
where Score >= s.Score
) as Rank
from Scores s
order by Rank asc
1.查詢當前分數的排名,一般是查詢大於等於當前分數的記錄總數,題目限制名次之間不應該有“間隔”
,所以需要去重。然後根據這個記錄總數去降序排序
select Score
,(
select count(distinct Score)
from Scores
where Score >= s.Score
) as Rank
from Scores s
order by Rank asc