Display ShipCity ShipState and Total Sales Determine ShipCit
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
Solution
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
![Display ShipCity, ShipState and Total Sales. Determine ShipCity and ShipState with Lowest total Sales [Total Sales = SUM(QUANTITY*Retail)]. The tables already e Display ShipCity, ShipState and Total Sales. Determine ShipCity and ShipState with Lowest total Sales [Total Sales = SUM(QUANTITY*Retail)]. The tables already e](/WebImages/33/display-shipcity-shipstate-and-total-sales-determine-shipcit-1096092-1761578026-0.webp)