Get Distinct Maximum Date

Get Distinct Maximum Date

Display the latest order of each customers.

SELECT A.CustomerID, OrderDate, EmployeeID, ShipperID FROM Orders AS A INNER JOIN
(SELECT CustomerID, MAX(OrderDate) AS MaxOrderDate FROM Orders GROUP BY CustomerID) AS B
ON A.CustomerID=B.CustomerID AND A.OrderDate=B.MaxOrderDate

Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>