Alright, I’m trying to link three different tables (Customers, Orders, and Order Details), in an effort to figure out which customers ordered the same item twice. I’m stumped. Here’s what I’ve come up with thus far:
Select ContactName, Orders.OrderID, ProductID From Customers
inner join Orders on Customers.CustomerID = Orders.CustomerID
join [Order Details] on [Order Details].OrderID = Orders.OrderID;
I was thinking it’d be easiest to find ProductIDs that have the correlating ContactName but a different Orders.OrderID… and this is what I’m having trouble with. Any help would be much appreciated.
you need to select two different orders which have a detail with the same product. (“select all customers which have two different orders with the same product”)
or use a subquery. (“select all customers which have a product detail with the same product as in another order of the same customer”);
Or use group by. then you can count them. You can aggregate different values, for instance the total amount ordered or the total prize payed.