Home | Pinoy Relihiyoso | Sitemap

Monday, November 2, 2015

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

No comments :

Post a Comment