SQL-排名函数
/* 人员:LDH 功能:SQL-排名函数 日期:2018-7-18 */ USE TSQLFundamentals2008; GO -- ROW_NUMBER() SELECT ROW_NUMBER() OVER (ORDER BY lastname ASC) AS 'RowNo', lastname, firstname FROM HR.Employees;
-- RANK SELECT RANK() OVER (ORDER BY country ASC) AS 'RANK排名', country, lastname, firstname FROM HR.Employees;
-- DENSE_RANK SELECT DENSE_RANK() OVER (ORDER BY country ASC) AS '密集排名DENSE_RANK', DENSE_RANK() OVER (ORDER BY lastname ASC) AS '密集排名名字', country, lastname, firstname FROM HR.Employees;
SELECT custid, orderdate, orderid, RowNo = ROW_NUMBER() OVER (PARTITION BY custid ORDER BY orderdate, orderid ) FROM Sales.Orders;
本文作者:Love In Winter
本文链接:https://www.cnblogs.com/LifeDecidesHappiness/p/9338519.html
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以扫一扫,任意打赏,您的鼓励是博主的最大动力!
本文链接:https://www.cnblogs.com/LifeDecidesHappiness/p/9338519.html
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以扫一扫,任意打赏,您的鼓励是博主的最大动力!
![扫一扫,支付宝打赏](https://files.cnblogs.com/files/LifeDecidesHappiness/%E6%94%AF%E4%BB%98%E5%AE%9D.bmp)
![扫一扫,微信打赏](https://files.cnblogs.com/files/LifeDecidesHappiness/%E5%BE%AE%E4%BF%A1%E6%94%B6%E6%AC%BE%E7%A0%81.bmp)