SQL-排名函数

原文链接:http://www.cnblogs.com/LifeDecidesHappiness/p/9338519.html
/*
    人员: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;

SQL-排名函数

-- RANK
SELECT RANK() OVER (ORDER BY country ASC) AS 'RANK排名',
    country,
    lastname,
    firstname
FROM HR.Employees;

SQL-排名函数

-- 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;

SQL-排名函数

SELECT custid,
    orderdate,
    orderid,
    RowNo = ROW_NUMBER() OVER (PARTITION BY custid
                               ORDER BY orderdate,
                                   orderid
                              )
FROM Sales.Orders;

SQL-排名函数

转载于:https://www.cnblogs.com/LifeDecidesHappiness/p/9338519.html

上一篇:Paper | Dynamic Residual Dense Network for Image Denoising


下一篇:1.线性回归