Sunday, April 27, 2014

which item has been sold more than once to the same customer by the same employee ?

Try this:



SELECT ProductID, CustomerID, EmployeeID, COUNT(*)
FROM Orders
INNER JOIN OrderDetails
ON Orders.OrderID = OrderDetails .OrderID
GROUP BY ProductID, CustomerID, EmployeeID
HAVING COUNT(*) > 1



Hope this helps.

~ J.

No comments:

Post a Comment