排名的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
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
原文地址:http://blog.csdn.net/cuijian_ok/archive/2005/03/21/325243.aspx
轉載于:https://www.cnblogs.com/Nina-piaoye/archive/2006/10/16/530102.html
總結
- 上一篇: 最大化BEA WebLogic Clus
- 下一篇: K线理论--单根K线形态