SQL SERVER – SELECTING TOP 1 IN A LEFT JOIN(SQL SERVER左连接与TOP 1同时使用)

引用地址https://himynameistim.wordpress.com/2014/04/07/sql-server-selecting-top-1-in-a-left-join/

SELECT c.*, la.*
FROM Customer c
OUTER APPLY 
    (SELECT TOP 1 *
    FROM Address a
    WHERE a.CustomerID = c.CustomerID
    ORDER BY a.DateAdded DESC
    ) AS la

猜你喜欢

转载自blog.csdn.net/sdhongjun/article/details/82812140