Display ShipCity, ShipState and Total Sales. Determine ShipCity and ShipState wi
ID: 3774404 • Letter: D
Question
Display ShipCity, ShipState and Total Sales. Determine ShipCity and ShipState with Lowest total Sales [Total Sales = SUM(QUANTITY*Retail)].
The tables already exist within my database, I just have to display the information above correctly, given the tables and attributes from the picture inserted.
I have been trying to work on it, and this is the code I currently have, but it does not execute correctly. What do I need to fix?
SELECT O.ShipCity, O.ShipState, SUM (T.QUANTITY*B.Retail) AS TotalSales
FROM Orders O, ORDERITEMS T , Books B
WHERE SUM (T.QUANTITY*B.Retail)=(SELECT MIN (SUM (T.QUANTITY*B.Retail) FROM Books)
GROUP BY O.ShipCity, O.ShipState
Explanation / Answer
Answer:-
SELECT O.ShipCity, O.ShipState, SUM (T.QUANTITY*B.Retail) AS TotalSales
FROM Orders O, ORDERITEMS T , Books B
WHERE SUM (T.QUANTITY*B.Retail)= MIN(T.QUANTITY*B.Retail) FROM Books
GROUP BY O.ShipCity, O.ShipState