日期:2014-05-18  浏览次数:20417 次

如何在SQL2000 中实现在结果集中加一个表示排名的列 下面是我的SQL 在线急等
select unitid,unitName,(select count(*) from t_news left join t_newstype on t_news.newstypeid=t_newstype.newstypeid where t_newstype.newsTongji=1 and unitId=t_unit.unitId and sysDate > '2007.01.01' and sysDate <'2008.02.01') as newsCount,(select count(*) from t_news left join t_newstype on t_news.newstypeid=t_newstype.newstypeid where t_newstype.newsTongji=1 and unitId=t_unit.unitId and newsState=1 and sysDate > '2007.01.01' and sysDate <'2008.02.01') as newsstatecount from t_unit where unitTypeId=1 order by newsCount desc,unitOrder

------解决方案--------------------
select ranking from (select dense_rank() over(partition by REID order by QUAmount) as ranking,QUID from QU ) as b


你参照一下ranking