Breaking News
Loading...
06/12/2013

Returns orders with the maximum order ID for each customer.

USE TSQL2012;
SELECT custid, orderid, orderdate, empid
FROM Sales.Orders AS O1
WHERE orderid =
(SELECT MAX(O2.orderid)
FROM Sales.Orders AS O2
WHERE O2.custid = O1.custid);

0 comments:

Post a Comment

 
Toggle Footer