[ { "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 products with low stock", "difficulty": "Beginner", "description": "Show products with stock less than 10 units.", "hint": "Use a WHERE clause to filter by stock.", "expected_sql": "SELECT product_name, stock FROM inventory WHERE stock < 10;" }, { "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.", "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 50 and 500, inclusive.", "hint": "Use a BETWEEN clause for the price range.", "expected_sql": "SELECT product_name, price FROM inventory WHERE price BETWEEN 50 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": "Products with no restocks", "difficulty": "Beginner", "description": "List products that have never been restocked.", "hint": "Use a LEFT JOIN and check for NULL in the restocks table.", "expected_sql": "SELECT i.product_name FROM inventory i LEFT JOIN restocks r ON i.product_id = r.product_id WHERE r.restock_id IS NULL;" }, { "id": "q7", "title": "Restocks in January 2023", "difficulty": "Beginner", "description": "Show all restocks that occurred in January 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-01%';" }, { "id": "q8", "title": "List products and categories", "difficulty": "Beginner", "description": "Show all product names and their categories.", "hint": "Select product_name and category from the inventory table.", "expected_sql": "SELECT product_name, category FROM inventory;" }, { "id": "q9", "title": "Find high-priced products", "difficulty": "Beginner", "description": "Retrieve products with a price greater than 1000.", "hint": "Use a WHERE clause to filter by price.", "expected_sql": "SELECT product_name, price FROM inventory WHERE price > 1000;" }, { "id": "q10", "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": "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 product price by category", "difficulty": "Intermediate", "description": "Find 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": "Restocks by supplier", "difficulty": "Intermediate", "description": "Count 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": "Show 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 by category", "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 products", "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 with high stock", "difficulty": "Intermediate", "description": "List products with stock greater than 20, ordered by stock descending.", "hint": "Use WHERE and ORDER BY clauses.", "expected_sql": "SELECT product_name, stock FROM inventory WHERE stock > 20 ORDER BY stock DESC;" }, { "id": "q19", "title": "Suppliers with large restocks", "difficulty": "Intermediate", "description": "Find suppliers who have restocked quantities greater than 10 in a single restock event.", "hint": "Use WHERE clause on quantity and select DISTINCT supplier.", "expected_sql": "SELECT DISTINCT supplier FROM restocks WHERE quantity > 10;" }, { "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": "Low stock high-value products", "difficulty": "Advanced", "description": "Identify products with stock less than 10 and price greater than 500.", "hint": "Use multiple conditions in the WHERE clause.", "expected_sql": "SELECT product_name, price, stock FROM inventory WHERE stock < 10 AND price > 500;" }, { "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 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, grouped 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 10.", "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 + 10;" }, { "id": "q29", "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": "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, grouped by supplier.", "expected_sql": "SELECT supplier, MIN(restock_date) AS earliest_restock, MAX(restock_date) AS latest_restock FROM restocks GROUP BY supplier;" } ]