|
[ |
|
{ |
|
"id": "q1", |
|
"title": "List all main course items", |
|
"difficulty": "Beginner", |
|
"description": "Retrieve the names and prices of all menu items in the Main Course category.", |
|
"hint": "Use a WHERE clause to filter by category.", |
|
"expected_sql": "SELECT name, price FROM menu_items WHERE category = 'Main Course';" |
|
}, |
|
{ |
|
"id": "q2", |
|
"title": "Find orders by customer ID 1", |
|
"difficulty": "Beginner", |
|
"description": "Show all orders placed by the customer with ID 1.", |
|
"hint": "Use a WHERE clause to filter by customer_id.", |
|
"expected_sql": "SELECT order_id, order_date, total_amount FROM orders WHERE customer_id = 1;" |
|
}, |
|
{ |
|
"id": "q3", |
|
"title": "List all beverages", |
|
"difficulty": "Beginner", |
|
"description": "Retrieve the names and prices of all items in the Beverage category.", |
|
"hint": "Use a WHERE clause to filter by category.", |
|
"expected_sql": "SELECT name, price FROM menu_items WHERE category = 'Beverage';" |
|
}, |
|
{ |
|
"id": "q4", |
|
"title": "Find orders on June 11, 2023", |
|
"difficulty": "Beginner", |
|
"description": "Show all orders placed on June 11, 2023.", |
|
"hint": "Use a WHERE clause with date comparison.", |
|
"expected_sql": "SELECT order_id, customer_id, total_amount FROM orders WHERE order_date = '2023-06-11';" |
|
}, |
|
{ |
|
"id": "q5", |
|
"title": "List unique customer emails", |
|
"difficulty": "Beginner", |
|
"description": "Retrieve all unique customer email addresses.", |
|
"hint": "Use DISTINCT to avoid duplicate emails.", |
|
"expected_sql": "SELECT DISTINCT email FROM customers;" |
|
}, |
|
{ |
|
"id": "q6", |
|
"title": "Items in order ID 3", |
|
"difficulty": "Beginner", |
|
"description": "Show the menu items and quantities for order ID 3.", |
|
"hint": "Join order_items with menu_items and filter by order_id.", |
|
"expected_sql": "SELECT m.name, oi.quantity FROM order_items oi JOIN menu_items m ON oi.item_id = m.item_id WHERE oi.order_id = 3;" |
|
}, |
|
{ |
|
"id": "q7", |
|
"title": "List customer contact details", |
|
"difficulty": "Beginner", |
|
"description": "Show names and contact numbers of all customers.", |
|
"hint": "Select name and contact from the customers table.", |
|
"expected_sql": "SELECT name, contact FROM customers;" |
|
}, |
|
{ |
|
"id": "q8", |
|
"title": "Find high-priced items", |
|
"difficulty": "Beginner", |
|
"description": "Retrieve menu items with a price greater than 150.", |
|
"hint": "Use a WHERE clause to filter by price.", |
|
"expected_sql": "SELECT name, price FROM menu_items WHERE price > 150;" |
|
}, |
|
{ |
|
"id": "q9", |
|
"title": "List all order items", |
|
"difficulty": "Beginner", |
|
"description": "Show all order items with their quantities.", |
|
"hint": "Select from the order_items table.", |
|
"expected_sql": "SELECT order_item_id, order_id, item_id, quantity FROM order_items;" |
|
}, |
|
{ |
|
"id": "q10", |
|
"title": "Find orders above 300", |
|
"difficulty": "Beginner", |
|
"description": "Show orders with a total amount greater than 300.", |
|
"hint": "Use a WHERE clause to filter by total_amount.", |
|
"expected_sql": "SELECT order_id, customer_id, total_amount FROM orders WHERE total_amount > 300;" |
|
}, |
|
{ |
|
"id": "q11", |
|
"title": "Count orders per customer", |
|
"difficulty": "Intermediate", |
|
"description": "Show the number of orders placed by each customer, including those with zero orders.", |
|
"hint": "Use a LEFT JOIN and GROUP BY customer name.", |
|
"expected_sql": "SELECT c.name, COUNT(o.order_id) AS order_count FROM customers c LEFT JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.name;" |
|
}, |
|
{ |
|
"id": "q12", |
|
"title": "Total items ordered per category", |
|
"difficulty": "Intermediate", |
|
"description": "Calculate the total quantity of items ordered for each menu item category.", |
|
"hint": "Join menu_items and order_items, then GROUP BY category.", |
|
"expected_sql": "SELECT m.category, SUM(oi.quantity) AS total_quantity FROM menu_items m JOIN order_items oi ON m.item_id = oi.item_id GROUP BY m.category;" |
|
}, |
|
{ |
|
"id": "q13", |
|
"title": "Average order amount", |
|
"difficulty": "Intermediate", |
|
"description": "Calculate the average total amount of all orders.", |
|
"hint": "Use AVG on total_amount in the orders table.", |
|
"expected_sql": "SELECT AVG(total_amount) AS avg_order_amount FROM orders;" |
|
}, |
|
{ |
|
"id": "q14", |
|
"title": "Most ordered menu item", |
|
"difficulty": "Intermediate", |
|
"description": "Identify the menu item with the highest total quantity ordered.", |
|
"hint": "Join order_items and menu_items, GROUP BY item name, and use LIMIT.", |
|
"expected_sql": "SELECT m.name, SUM(oi.quantity) AS total_quantity FROM menu_items m JOIN order_items oi ON m.item_id = oi.item_id GROUP BY m.name ORDER BY total_quantity DESC LIMIT 1;" |
|
}, |
|
{ |
|
"id": "q15", |
|
"title": "Customers with multiple orders", |
|
"difficulty": "Intermediate", |
|
"description": "Find customers who have placed more than one order.", |
|
"hint": "Use GROUP BY on customer name and HAVING clause.", |
|
"expected_sql": "SELECT c.name, COUNT(o.order_id) AS order_count FROM customers c JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.name HAVING COUNT(o.order_id) > 1;" |
|
}, |
|
{ |
|
"id": "q16", |
|
"title": "Menu items never ordered", |
|
"difficulty": "Intermediate", |
|
"description": "List menu items that have never been ordered.", |
|
"hint": "Use a LEFT JOIN and check for NULL in the order_items table.", |
|
"expected_sql": "SELECT m.name FROM menu_items m LEFT JOIN order_items oi ON m.item_id = oi.item_id WHERE oi.order_item_id IS NULL;" |
|
}, |
|
{ |
|
"id": "q17", |
|
"title": "Order details with items", |
|
"difficulty": "Intermediate", |
|
"description": "Show order details including customer name and menu items for each order.", |
|
"hint": "Join orders, customers, order_items, and menu_items tables.", |
|
"expected_sql": "SELECT o.order_id, c.name AS customer_name, m.name AS item_name, oi.quantity FROM orders o JOIN customers c ON o.customer_id = c.customer_id JOIN order_items oi ON o.order_id = oi.order_id JOIN menu_items m ON oi.item_id = m.item_id;" |
|
}, |
|
{ |
|
"id": "q18", |
|
"title": "Total revenue per customer", |
|
"difficulty": "Intermediate", |
|
"description": "Calculate the total amount spent by each customer based on order totals.", |
|
"hint": "Use GROUP BY on customer name and SUM on total_amount.", |
|
"expected_sql": "SELECT c.name, SUM(o.total_amount) AS total_spent FROM customers c JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.name;" |
|
}, |
|
{ |
|
"id": "q19", |
|
"title": "Orders with multiple items", |
|
"difficulty": "Intermediate", |
|
"description": "List orders that include more than one type of menu item.", |
|
"hint": "Use GROUP BY on order_id and HAVING clause on COUNT of item_id.", |
|
"expected_sql": "SELECT o.order_id, COUNT(oi.item_id) AS item_count FROM orders o JOIN order_items oi ON o.order_id = oi.order_id GROUP BY o.order_id HAVING COUNT(oi.item_id) > 1;" |
|
}, |
|
{ |
|
"id": "q20", |
|
"title": "Items ordered with high quantity", |
|
"difficulty": "Intermediate", |
|
"description": "Show menu items with a total ordered quantity greater than 2.", |
|
"hint": "Join order_items and menu_items, GROUP BY item name, and use HAVING.", |
|
"expected_sql": "SELECT m.name, SUM(oi.quantity) AS total_quantity FROM menu_items m JOIN order_items oi ON m.item_id = oi.item_id GROUP BY m.name HAVING SUM(oi.quantity) > 2;" |
|
}, |
|
{ |
|
"id": "q21", |
|
"title": "Customer order value analysis", |
|
"difficulty": "Advanced", |
|
"description": "Calculate the total value of orders (sum of price * quantity) for each customer.", |
|
"hint": "Join all tables, multiply price by quantity, and GROUP BY customer name.", |
|
"expected_sql": "SELECT c.name, SUM(m.price * oi.quantity) AS total_order_value FROM customers c JOIN orders o ON c.customer_id = o.customer_id JOIN order_items oi ON o.order_id = oi.order_id JOIN menu_items m ON oi.item_id = m.item_id GROUP BY c.name;" |
|
}, |
|
{ |
|
"id": "q22", |
|
"title": "Most expensive order", |
|
"difficulty": "Advanced", |
|
"description": "Identify the order with the highest calculated total based on item prices and quantities.", |
|
"hint": "Join orders, order_items, and menu_items, calculate total, and use LIMIT.", |
|
"expected_sql": "SELECT o.order_id, SUM(m.price * oi.quantity) AS calculated_total FROM orders o JOIN order_items oi ON o.order_id = oi.order_id JOIN menu_items m ON oi.item_id = m.item_id GROUP BY o.order_id ORDER BY calculated_total DESC LIMIT 1;" |
|
}, |
|
{ |
|
"id": "q23", |
|
"title": "Customers ordering all main courses", |
|
"difficulty": "Advanced", |
|
"description": "Find customers who have ordered every item in the Main Course category.", |
|
"hint": "Count distinct Main Course items per customer and compare with total Main Course items.", |
|
"expected_sql": "SELECT c.name FROM customers c JOIN orders o ON c.customer_id = o.customer_id JOIN order_items oi ON o.order_id = oi.order_id JOIN menu_items m ON oi.item_id = m.item_id WHERE m.category = 'Main Course' GROUP BY c.name HAVING COUNT(DISTINCT m.item_id) = (SELECT COUNT(*) FROM menu_items WHERE category = 'Main Course');" |
|
}, |
|
{ |
|
"id": "q24", |
|
"title": "Average item price per order", |
|
"difficulty": "Advanced", |
|
"description": "Calculate the average price of items in each order.", |
|
"hint": "Join order_items and menu_items, GROUP BY order_id, and use AVG.", |
|
"expected_sql": "SELECT o.order_id, AVG(m.price) AS avg_item_price FROM orders o JOIN order_items oi ON o.order_id = oi.order_id JOIN menu_items m ON oi.item_id = m.item_id GROUP BY o.order_id;" |
|
}, |
|
{ |
|
"id": "q25", |
|
"title": "Order frequency by date", |
|
"difficulty": "Advanced", |
|
"description": "Show the number of orders placed on each date in June 2023.", |
|
"hint": "Use GROUP BY on order_date and COUNT.", |
|
"expected_sql": "SELECT order_date, COUNT(order_id) AS order_count FROM orders WHERE order_date LIKE '2023-06%' GROUP BY order_date;" |
|
}, |
|
{ |
|
"id": "q26", |
|
"title": "Customers who ordered Margherita Pizza", |
|
"difficulty": "Advanced", |
|
"description": "List customers who have ordered a Margherita Pizza.", |
|
"hint": "Join all tables and filter by item name.", |
|
"expected_sql": "SELECT DISTINCT c.name FROM customers c JOIN orders o ON c.customer_id = o.customer_id JOIN order_items oi ON o.order_id = oi.order_id JOIN menu_items m ON oi.item_id = m.item_id WHERE m.name = 'Margherita Pizza';" |
|
}, |
|
{ |
|
"id": "q27", |
|
"title": "Category revenue contribution", |
|
"difficulty": "Advanced", |
|
"description": "Calculate the total revenue generated by each menu item category.", |
|
"hint": "Join menu_items and order_items, multiply price by quantity, and GROUP BY category.", |
|
"expected_sql": "SELECT m.category, SUM(m.price * oi.quantity) AS total_revenue FROM menu_items m JOIN order_items oi ON m.item_id = oi.item_id GROUP BY m.category;" |
|
}, |
|
{ |
|
"id": "q28", |
|
"title": "Orders with high item diversity", |
|
"difficulty": "Advanced", |
|
"description": "Find orders that include items from more than one category.", |
|
"hint": "Join tables, GROUP BY order_id, and COUNT distinct categories.", |
|
"expected_sql": "SELECT o.order_id, COUNT(DISTINCT m.category) AS category_count FROM orders o JOIN order_items oi ON o.order_id = oi.order_id JOIN menu_items m ON oi.item_id = m.item_id GROUP BY o.order_id HAVING COUNT(DISTINCT m.category) > 1;" |
|
}, |
|
{ |
|
"id": "q29", |
|
"title": "Customer spending rank", |
|
"difficulty": "Advanced", |
|
"description": "Rank customers by their total spending (sum of order totals).", |
|
"hint": "Use GROUP BY on customer name, SUM, and ORDER BY.", |
|
"expected_sql": "SELECT c.name, SUM(o.total_amount) AS total_spent FROM customers c JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.name ORDER BY total_spent DESC;" |
|
}, |
|
{ |
|
"id": "q30", |
|
"title": "Items with high revenue contribution", |
|
"difficulty": "Advanced", |
|
"description": "Identify menu items contributing more than 200 in total revenue (price * quantity).", |
|
"hint": "Join menu_items and order_items, calculate revenue, and use HAVING.", |
|
"expected_sql": "SELECT m.name, SUM(m.price * oi.quantity) AS total_revenue FROM menu_items m JOIN order_items oi ON m.item_id = oi.item_id GROUP BY m.name HAVING SUM(m.price * oi.quantity) > 200;" |
|
} |
|
] |
|
|