兩條關於生成排名的SQL語句

兩條關於生成排名的SQL語句:
select name,score,(select count(*) from t where score>a.score)+1
from t a
order by score
上面是:1,2,3,3,3,6,7...
下面是:1,2,3,3,3,4,5
select name,score,(select count(distinct score) from t where score>a.score)+1
from t a
order by score
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章