您的位置:首页 > 数据库

两条关于生成排名的SQL语句

2005-01-07 17:40 369 查看
两条关于生成排名的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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: