0

I have a basic database for a retail store with 4 tables, one of which stores Order info, one that stores Product info and one that stores Supplier info.

I am trying to run a query that will display total sum of stock sold figure (in dollars) with a GROUP BY supplier with ROLL UP. I have a feeling that SUM should be in the code but I can't find where to put it, so far I have this:

SELECT ORDERS.OrderPrice, PRODUCT.SupplierID, SUPPLIER.SupplierName
FROM ((ORDERS
INNER JOIN PRODUCT ON ORDERS.ProductID = PRODUCT.ProductID)
INNER JOIN SUPPLIER ON PRODUCT.SupplierID = SUPPLIER.SupplierID)
GROUP BY SupplierName WITH ROLLUP;

The database can be viewed on DB Fiddle here:

https://www.db-fiddle.com/f/qS515ShyFGxgj4h6Ga6HA3/1#&togetherjs=aNgE8G0yMh

Any ideas? Thanks

  • Your fiddle have an error. What's that on line 107 ? – DEarTh Apr 14 '18 at 5:50
  • SUM(ORDERS.OrderPrice) that should do it. – DEarTh Apr 14 '18 at 6:01
0

You must use SUM function with orderPrice

SELECT SUM(ORDERS.OrderPrice), SUPPLIER.SupplierName FROM ((ORDERS INNER JOIN PRODUCT ON ORDERS.ProductID = PRODUCT.ProductID) INNER JOIN SUPPLIER ON PRODUCT.SupplierID = SUPPLIER.SupplierID) GROUP BY SupplierName with ROLLUP 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.