子查詢
select he.empid , he.lastname, dt.orderid from HR.Employees he cross apply ( select distinct top 3 so.orderdate, so.orderid from Sales.Orders so where so.empid = he.empid order by so.orderdate desc ) as dt order by he.empid
select he.empid , he.lastname, dt.orderid from HR.Employees he cross apply ( select distinct top 3 so.orderdate, so.orderid from Sales.Orders so where so.empid = he.empid order by so.orderdate desc ) as dt order by he.empid