SQL 内置排名函数 DENSE_RANK

求排名前五的数据信息:

实现一:

select distinct top 5 Id,Title,sort from content order by sort DESC

实现二:

select * from (select dense_rank() over(order by sort desc) rank,Id,Title,sort from content ) AS cte where rank < 6

分别对应的结果:

 

posted @ 2015-09-26 08:48  BloggerYan  阅读(...)  评论(...编辑  收藏