Last active
January 8, 2024 18:57
-
-
Save mohibbulla-munshi/423bb763b94b81d4295377eaaf5ef9a2 to your computer and use it in GitHub Desktop.
Assignment 2- Mohibbulla Munshi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
এক্সাম উইক ২ এর এসাইনমেন্ট | |
Cloud Kitchen Activities and Analysis |
Revenue by Cuisine: Calculate the total revenue for each cuisine based on completed orders.
SELECT
d.cuisine,
SUM(o.total_amount) as total_revenue
FROM
orders o
JOIN order_items oi ON o.id = oi.order_id
JOIN dishes d ON oi.dish_id = d.id
WHERE
o.status = 'Completed'
GROUP BY
d.cuisine;
Popular Dish:: Identify the most ordered dish and display its details.
SELECT
d.name,
d.description,
SUM(oi.quantity) as total_quantity_ordered
FROM
order_items oi
JOIN dishes d ON oi.dish_id = d.id
GROUP BY
d.name, d.description
ORDER BY
total_quantity_ordered DESC
LIMIT 1;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
User Order History: Retrieve the order history for a specific user, showing order details (order date, total amount, status) and the list of dishes in each order.
select
o.order_date,
o.total_amount,
o.status,
d.description
from
orders o
join order_items oi on o.id = oi.order_id
join dishes d on oi.dish_id = d.id
where
o.user_id = 2