Add query optimization scripts and results

This commit is contained in:
2024-11-17 14:47:57 +01:00
parent aac9358de5
commit 05e2863bfd
4 changed files with 83 additions and 0 deletions

15
sql/get_order_detail.sql Normal file
View File

@@ -0,0 +1,15 @@
-- query optimization - task 2
-- changes:
-- interpreted quantity as the number of items in an order, because I assumed that Little lemon wants
-- orders à la carte instead of fixed menus
prepare GetOrderDetail from "
select
O.OrderID,
count(OI.MenuItemID) as Quantity,
O.BillAmount as Cost
from Orders as O
inner join OrderItems as OI on O.OrderID = OI.OrderID
inner join Bookings as B on O.BookingID = B.BookingID
where B.CustomerID = ?;
";