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