Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Database Systems Provide working SQL DML statements for the following database s

ID: 3723452 • Letter: D

Question

Database Systems

Provide working SQL DML statements for the following database schema and queries EXERCISE CUSTOMER , Type, Firstname, Lastname, Address, City) INVENTORY(ID, ItemName, Type, MadeInStore, SupplierName, DailyAverageSold, Price) ORDERS, Customer FK. Item-FK, Quantity, DeliveryDate) 14. Find the total amount due for each order - Show: order id, lastname, and total-amount Hint: variation of previous query Find the total amount due for each order placed by a customer that is a restaurant owner 15. - Show: order id, lastname, and total-amount Hint: variation of previous query

Explanation / Answer

Answer:

14.select o.ID,c.Lastname,sum(i.Price)
from ORDERS o join CUSTOMER c on c.ID = o.Customer_FK
join INVENTORY i on i.ID = o.Item_FK
group by o.ID,c.Lastname /*This will list out the total amount due for each order*/

15.select o.ID,c.Lastname,sum(i.Price)
from ORDERS o join CUSTOMER c on c.ID = o.Customer_FK
join INVENTORY i on i.ID = o.Item_FK
where SupplierName = '%Restaurant Owner%'
group by o.ID,c.Lastname/*This will list out the total amount due for each order placed by restaurant owner*/