pwinstanley
IS-IT--Management
I'm trying to create a best sellers chart for my eCommerce site. I have put in place the following query
SELECT dbrderDetails.productID, sum(Quantity) as Quantity
FROM dbrderDetails GROUP BY dbrderDetails.productID
ORDER BY 2 DESC
which gives me the productID with most sales at the top and works fine.
My problem is that I need to get the productname from another table, the Products table. The orderDetails and Product table are related through the productID field.
Thing is as soon as I introduce another element to the group by section it all goes wrong. Do I need to use a join as well rather than stating from dbrderDetails, dbo.Product?
Argggghhh!! Please help!
Cheers
Paul
SELECT dbrderDetails.productID, sum(Quantity) as Quantity
FROM dbrderDetails GROUP BY dbrderDetails.productID
ORDER BY 2 DESC
which gives me the productID with most sales at the top and works fine.
My problem is that I need to get the productname from another table, the Products table. The orderDetails and Product table are related through the productID field.
Thing is as soon as I introduce another element to the group by section it all goes wrong. Do I need to use a join as well rather than stating from dbrderDetails, dbo.Product?
Argggghhh!! Please help!
Cheers
Paul