Skip to content

Instantly share code, notes, and snippets.

@mohibbulla-munshi
Last active January 8, 2024 18:57
Show Gist options
  • Save mohibbulla-munshi/423bb763b94b81d4295377eaaf5ef9a2 to your computer and use it in GitHub Desktop.
Save mohibbulla-munshi/423bb763b94b81d4295377eaaf5ef9a2 to your computer and use it in GitHub Desktop.
Assignment 2- Mohibbulla Munshi
এক্সাম উইক ২ এর এসাইনমেন্ট
Cloud Kitchen Activities and Analysis
@mohibbulla-munshi
Copy link
Author

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

@mohibbulla-munshi
Copy link
Author

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;

@mohibbulla-munshi
Copy link
Author

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