-- 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 = ?;
";
