SQL几类排名函数的使用介绍

--查询出各类排名
SELECT orderid,qty,
  ROW_NUMBER() OVER(ORDER BY qty) AS rownumber,--序号
  RANK()       OVER(ORDER BY qty) AS [rank],--断开的排名
  DENSE_RANK() OVER(ORDER BY qty) AS denserank ,--连续的排名
  NTILE(4) OVER(ORDER BY qty) AS [NTILE]--均分成四个数组
FROM rankorder
ORDER BY qty

 

posted @ 2013-07-17 21:00  Tom Fan  阅读(194)  评论(0编辑  收藏  举报