I'm trying to create a query to find out the quantity sold of each of our products. The query takes two date ranges and should return the quantity sold totals for each of the date ranges. I'm trying to use a subquery but the way I'm writing it gives me errors. I understand why I get the errors, but I can't think of a way to do it. Here's a simplified version of what I'm trying to do.
Select S.Stock_ID, Sum(OD.QTY) AS QTY,
(Select Sum(OD.QTY) AS QTY,
From Stock S, Order_Detail OD, Orders O
Where S.Stock_ID = OD.Stock_ID and O.Order_ID=OD.Order_ID
Group By S.Stock_ID) AS QTY2
From Stock S, Order_Detail OD, Orders O
Where S.Stock_ID = OD.Stock_ID and O.Order_ID = OD.Order_ID
Group By S.Stock_ID
Any help would be greatly appreciated. Thanks
Select S.Stock_ID, Sum(OD.QTY) AS QTY,
(Select Sum(OD.QTY) AS QTY,
From Stock S, Order_Detail OD, Orders O
Where S.Stock_ID = OD.Stock_ID and O.Order_ID=OD.Order_ID
Group By S.Stock_ID) AS QTY2
From Stock S, Order_Detail OD, Orders O
Where S.Stock_ID = OD.Stock_ID and O.Order_ID = OD.Order_ID
Group By S.Stock_ID
Any help would be greatly appreciated. Thanks