File size: 11,745 Bytes
e7cf806 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
[
{
"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;"
}
]
|