[ { "id": "q1", "title": "List electronics products", "difficulty": "Beginner", "description": "Retrieve the names and prices of all products in the Electronics category.", "hint": "Use a WHERE clause to filter by category.", "expected_sql": "SELECT product_name, price FROM inventory WHERE category = 'Electronics';" }, { "id": "q2", "title": "Find low stock products", "difficulty": "Beginner", "description": "Show products with stock below their reorder level.", "hint": "Use a WHERE clause to compare stock and reorder_level.", "expected_sql": "SELECT product_name, stock, reorder_level FROM inventory WHERE stock < reorder_level;" }, { "id": "q3", "title": "List restocks for product ID 1", "difficulty": "Beginner", "description": "Retrieve all restock details for the product with ID 1.", "hint": "Use a WHERE clause to filter by product_id in the restocks table.", "expected_sql": "SELECT restock_id, restock_date, quantity, supplier FROM restocks WHERE product_id = 1;" }, { "id": "q4", "title": "Find products by price range", "difficulty": "Beginner", "description": "Show products with prices between 100 and 500, inclusive.", "hint": "Use a BETWEEN clause for the price range.", "expected_sql": "SELECT product_name, price FROM inventory WHERE price BETWEEN 100 AND 500;" }, { "id": "q5", "title": "List unique suppliers", "difficulty": "Beginner", "description": "Retrieve all unique suppliers from the restocks table.", "hint": "Use DISTINCT to avoid duplicate suppliers.", "expected_sql": "SELECT DISTINCT supplier FROM restocks;" }, { "id": "q6", "title": "Find restocks in 2023", "difficulty": "Beginner", "description": "Show all restocks that occurred in 2023.", "hint": "Use a WHERE clause with LIKE for restock_date.", "expected_sql": "SELECT restock_id, product_id, restock_date, quantity FROM restocks WHERE restock_date LIKE '2023%';" }, { "id": "q7", "title": "List accessories products", "difficulty": "Beginner", "description": "Retrieve product names and stock for all items in the Accessories category.", "hint": "Use a WHERE clause to filter by category.", "expected_sql": "SELECT product_name, stock FROM inventory WHERE category = 'Accessories';" }, { "id": "q8", "title": "Find high stock products", "difficulty": "Beginner", "description": "Show products with stock greater than 20.", "hint": "Use a WHERE clause to filter by stock.", "expected_sql": "SELECT product_name, stock FROM inventory WHERE stock > 20;" }, { "id": "q9", "title": "List restock quantities", "difficulty": "Beginner", "description": "Show the quantity restocked for each restock event.", "hint": "Select restock_id and quantity from the restocks table.", "expected_sql": "SELECT restock_id, quantity FROM restocks;" }, { "id": "q10", "title": "Find products with high reorder level", "difficulty": "Beginner", "description": "Retrieve products with a reorder level greater than 5.", "hint": "Use a WHERE clause to filter by reorder_level.", "expected_sql": "SELECT product_name, reorder_level FROM inventory WHERE reorder_level > 5;" }, { "id": "q11", "title": "Total stock per category", "difficulty": "Intermediate", "description": "Calculate the total stock for each product category.", "hint": "Use GROUP BY on category and SUM on stock.", "expected_sql": "SELECT category, SUM(stock) AS total_stock FROM inventory GROUP BY category;" }, { "id": "q12", "title": "Average price per category", "difficulty": "Intermediate", "description": "Calculate the average price of products in each category.", "hint": "Use GROUP BY on category and AVG on price.", "expected_sql": "SELECT category, AVG(price) AS avg_price FROM inventory GROUP BY category;" }, { "id": "q13", "title": "Count restocks per supplier", "difficulty": "Intermediate", "description": "Show the number of restock events for each supplier.", "hint": "Use GROUP BY on supplier and COUNT.", "expected_sql": "SELECT supplier, COUNT(restock_id) AS restock_count FROM restocks GROUP BY supplier;" }, { "id": "q14", "title": "Total restock quantity per product", "difficulty": "Intermediate", "description": "Calculate the total quantity restocked for each product.", "hint": "Join inventory and restocks, then GROUP BY product_name.", "expected_sql": "SELECT i.product_name, SUM(r.quantity) AS total_restocked FROM inventory i JOIN restocks r ON i.product_id = r.product_id GROUP BY i.product_name;" }, { "id": "q15", "title": "Products with multiple restocks", "difficulty": "Intermediate", "description": "List products that have been restocked more than once.", "hint": "Use GROUP BY on product_name and HAVING clause.", "expected_sql": "SELECT i.product_name, COUNT(r.restock_id) AS restock_count FROM inventory i JOIN restocks r ON i.product_id = r.product_id GROUP BY i.product_name HAVING COUNT(r.restock_id) > 1;" }, { "id": "q16", "title": "Total inventory value", "difficulty": "Intermediate", "description": "Calculate the total value of inventory (price * stock) for each category.", "hint": "Use GROUP BY on category and SUM on price * stock.", "expected_sql": "SELECT category, SUM(price * stock) AS total_value FROM inventory GROUP BY category;" }, { "id": "q17", "title": "Restock details with product names", "difficulty": "Intermediate", "description": "Show restock details including product names, quantities, and suppliers.", "hint": "Join inventory and restocks tables.", "expected_sql": "SELECT r.restock_id, i.product_name, r.restock_date, r.quantity, r.supplier FROM inventory i JOIN restocks r ON i.product_id = r.product_id;" }, { "id": "q18", "title": "Products needing restock", "difficulty": "Intermediate", "description": "List products with stock at or below their reorder level, ordered by stock ascending.", "hint": "Use WHERE and ORDER BY clauses.", "expected_sql": "SELECT product_name, stock, reorder_level FROM inventory WHERE stock <= reorder_level ORDER BY stock ASC;" }, { "id": "q19", "title": "Suppliers with large restocks", "difficulty": "Intermediate", "description": "Find suppliers who have restocked quantities greater than 20 in a single restock event.", "hint": "Use WHERE clause on quantity and select DISTINCT supplier.", "expected_sql": "SELECT DISTINCT supplier FROM restocks WHERE quantity > 20;" }, { "id": "q20", "title": "Restock frequency by product", "difficulty": "Intermediate", "description": "Show the number of restock events for each product, including those with zero restocks.", "hint": "Use a LEFT JOIN and GROUP BY product_name.", "expected_sql": "SELECT i.product_name, COUNT(r.restock_id) AS restock_count FROM inventory i LEFT JOIN restocks r ON i.product_id = r.product_id GROUP BY i.product_name;" }, { "id": "q21", "title": "Most expensive restocked product", "difficulty": "Advanced", "description": "Find the product with the highest price that has been restocked.", "hint": "Join inventory and restocks, use ORDER BY and LIMIT.", "expected_sql": "SELECT i.product_name, i.price FROM inventory i JOIN restocks r ON i.product_id = r.product_id ORDER BY i.price DESC LIMIT 1;" }, { "id": "q22", "title": "Total restock value per supplier", "difficulty": "Advanced", "description": "Calculate the total value of restocks (price * quantity) for each supplier.", "hint": "Join tables, multiply price by quantity, and GROUP BY supplier.", "expected_sql": "SELECT r.supplier, SUM(i.price * r.quantity) AS total_restock_value FROM inventory i JOIN restocks r ON i.product_id = r.product_id GROUP BY r.supplier;" }, { "id": "q23", "title": "Latest restock per product", "difficulty": "Advanced", "description": "Show the most recent restock date for each product that has been restocked.", "hint": "Use GROUP BY on product_name and MAX on restock_date.", "expected_sql": "SELECT i.product_name, MAX(r.restock_date) AS latest_restock FROM inventory i JOIN restocks r ON i.product_id = r.product_id GROUP BY i.product_name;" }, { "id": "q24", "title": "Suppliers restocking all electronics", "difficulty": "Advanced", "description": "List suppliers who have restocked every product in the Electronics category.", "hint": "Count distinct Electronics products per supplier and compare with total Electronics products.", "expected_sql": "SELECT r.supplier FROM restocks r JOIN inventory i ON r.product_id = i.product_id WHERE i.category = 'Electronics' GROUP BY r.supplier HAVING COUNT(DISTINCT r.product_id) = (SELECT COUNT(*) FROM inventory WHERE category = 'Electronics');" }, { "id": "q25", "title": "Restock trend by month", "difficulty": "Advanced", "description": "Show the total quantity restocked per month in 2023.", "hint": "Use STRFTIME to extract the month and GROUP BY.", "expected_sql": "SELECT STRFTIME('%Y-%m', restock_date) AS month, SUM(quantity) AS total_quantity FROM restocks WHERE restock_date LIKE '2023%' GROUP BY month;" }, { "id": "q26", "title": "Products with high restock value", "difficulty": "Advanced", "description": "Find products where the total restock value (price * quantity) exceeds 5000.", "hint": "Join tables, calculate value, and use HAVING clause.", "expected_sql": "SELECT i.product_name, SUM(i.price * r.quantity) AS total_restock_value FROM inventory i JOIN restocks r ON i.product_id = r.product_id GROUP BY i.product_name HAVING SUM(i.price * r.quantity) > 5000;" }, { "id": "q27", "title": "Supplier product diversity", "difficulty": "Advanced", "description": "Count the number of unique products each supplier has restocked.", "hint": "Use COUNT and DISTINCT on product_id, GROUP BY supplier.", "expected_sql": "SELECT r.supplier, COUNT(DISTINCT r.product_id) AS unique_products FROM restocks r GROUP BY r.supplier;" }, { "id": "q28", "title": "Overstocked products", "difficulty": "Advanced", "description": "Identify products where the total restocked quantity exceeds the current stock by more than 20.", "hint": "Join tables, compare SUM(quantity) with stock, and use HAVING.", "expected_sql": "SELECT i.product_name, i.stock, SUM(r.quantity) AS total_restocked FROM inventory i JOIN restocks r ON i.product_id = r.product_id GROUP BY i.product_name, i.stock HAVING SUM(r.quantity) > i.stock + 20;" }, { "id": "q29", "title": "Restock value by category", "difficulty": "Advanced", "description": "Calculate the total restock value (price * quantity) for each product category.", "hint": "Join tables, multiply price by quantity, and GROUP BY category.", "expected_sql": "SELECT i.category, SUM(i.price * r.quantity) AS total_restock_value FROM inventory i JOIN restocks r ON i.product_id = r.product_id GROUP BY i.category;" }, { "id": "q30", "title": "Earliest and latest restock per supplier", "difficulty": "Advanced", "description": "Show the earliest and latest restock dates for each supplier.", "hint": "Use MIN and MAX on restock_date, GROUP BY supplier.", "expected_sql": "SELECT supplier, MIN(restock_date) AS earliest_restock, MAX(restock_date) AS latest_restock FROM restocks GROUP BY supplier;" } ]