Spaces:
Sleeping
Sleeping
File size: 11,028 Bytes
64ccc23 | 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 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | [
{
"id": "medium_001",
"difficulty": "medium",
"schema": {
"tables": [
"users(id, name, email, age, city, active)",
"orders(id, user_id, product_id, amount, status, created_at)"
]
},
"intent": "Get names of users who have placed at least one order",
"broken_query": "SELECT name FROM users, orders WHERE users.id = orders.id",
"correct_query": "SELECT DISTINCT u.name FROM users u JOIN orders o ON u.id = o.user_id",
"error_type": "join",
"min_turns_expected": 2,
"clarification_answers": {
"join column in orders": "user_id links to users.id",
"orders foreign key": "orders.user_id references users.id"
}
},
{
"id": "medium_002",
"difficulty": "medium",
"schema": {
"tables": [
"users(id, name, email, age, city, active)",
"orders(id, user_id, product_id, amount, status, created_at)"
]
},
"intent": "Find total amount spent per user, show user name and total",
"broken_query": "SELECT name, SUM(amount) FROM users JOIN orders ON users.id = orders.id GROUP BY name",
"correct_query": "SELECT u.name, SUM(o.amount) AS total FROM users u JOIN orders o ON u.id = o.user_id GROUP BY u.id, u.name",
"error_type": "join",
"min_turns_expected": 2,
"clarification_answers": {
"join key": "orders.user_id = users.id",
"amount column": "in orders table, type REAL"
}
},
{
"id": "medium_003",
"difficulty": "medium",
"schema": {
"tables": [
"users(id, name, email, age, city, active)",
"orders(id, user_id, product_id, amount, status, created_at)"
]
},
"intent": "Get users who have never placed an order",
"broken_query": "SELECT * FROM users WHERE id NOT IN (SELECT id FROM orders)",
"correct_query": "SELECT * FROM users WHERE id NOT IN (SELECT user_id FROM orders)",
"error_type": "logic",
"min_turns_expected": 2,
"clarification_answers": {
"orders column for user": "user_id, not id"
}
},
{
"id": "medium_004",
"difficulty": "medium",
"schema": {
"tables": [
"users(id, name, email, age, city, active)",
"orders(id, user_id, product_id, amount, status, created_at)"
]
},
"intent": "Find all delivered orders with the buyer's name",
"broken_query": "SELECT users.name, orders.amount FROM users RIGHT JOIN orders WHERE status = 'delivered'",
"correct_query": "SELECT u.name, o.amount FROM users u JOIN orders o ON u.id = o.user_id WHERE o.status = 'delivered'",
"error_type": "join",
"min_turns_expected": 2,
"clarification_answers": {
"status values": "pending, shipped, delivered, cancelled",
"join syntax": "ON u.id = o.user_id"
}
},
{
"id": "medium_005",
"difficulty": "medium",
"schema": {
"tables": [
"users(id, name, email, age, city, active)",
"orders(id, user_id, product_id, amount, status, created_at)"
]
},
"intent": "Count orders per user only for active users",
"broken_query": "SELECT user_id, COUNT(*) FROM orders GROUP BY user_id WHERE active = 1",
"correct_query": "SELECT o.user_id, COUNT(*) FROM orders o JOIN users u ON o.user_id = u.id WHERE u.active = 1 GROUP BY o.user_id",
"error_type": "logic",
"min_turns_expected": 2,
"clarification_answers": {
"where vs having": "WHERE must come before GROUP BY",
"active column location": "active is in users table"
}
},
{
"id": "medium_006",
"difficulty": "medium",
"schema": {
"tables": [
"orders(id, user_id, product_id, amount, status, created_at)",
"products(id, name, category, price, stock)"
]
},
"intent": "Get product names and total revenue for electronics category",
"broken_query": "SELECT name, SUM(amount) FROM products JOIN orders ON products.id = orders.id WHERE category = 'electronics'",
"correct_query": "SELECT p.name, SUM(o.amount) AS revenue FROM products p JOIN orders o ON p.id = o.product_id WHERE p.category = 'electronics' GROUP BY p.id, p.name",
"error_type": "join",
"min_turns_expected": 2,
"clarification_answers": {
"join key for products and orders": "orders.product_id = products.id",
"category values": "stationery, electronics, furniture"
}
},
{
"id": "medium_007",
"difficulty": "medium",
"schema": {
"tables": [
"orders(id, user_id, product_id, amount, status, created_at)",
"products(id, name, category, price, stock)"
]
},
"intent": "Find products that have never been ordered",
"broken_query": "SELECT * FROM products WHERE id NOT IN (SELECT id FROM orders)",
"correct_query": "SELECT * FROM products WHERE id NOT IN (SELECT product_id FROM orders)",
"error_type": "logic",
"min_turns_expected": 2,
"clarification_answers": {
"orders column for product": "product_id, not id"
}
},
{
"id": "medium_008",
"difficulty": "medium",
"schema": {
"tables": [
"users(id, name, email, age, city, active)",
"orders(id, user_id, product_id, amount, status, created_at)"
]
},
"intent": "Get total amount of cancelled orders per city",
"broken_query": "SELECT city, SUM(amount) FROM orders WHERE status = 'cancelled' GROUP BY city",
"correct_query": "SELECT u.city, SUM(o.amount) AS cancelled_total FROM users u JOIN orders o ON u.id = o.user_id WHERE o.status = 'cancelled' GROUP BY u.city",
"error_type": "join",
"min_turns_expected": 2,
"clarification_answers": {
"city column location": "city is in the users table",
"cancelled status spelling": "cancelled with double l"
}
},
{
"id": "medium_009",
"difficulty": "medium",
"schema": {
"tables": [
"users(id, name, email, age, city, active)",
"orders(id, user_id, product_id, amount, status, created_at)"
]
},
"intent": "Find users who placed more than 2 orders",
"broken_query": "SELECT name FROM users JOIN orders ON users.id = orders.user_id WHERE COUNT(*) > 2",
"correct_query": "SELECT u.name FROM users u JOIN orders o ON u.id = o.user_id GROUP BY u.id, u.name HAVING COUNT(*) > 2",
"error_type": "logic",
"min_turns_expected": 2,
"clarification_answers": {
"aggregate filter": "use HAVING not WHERE for aggregate conditions"
}
},
{
"id": "medium_010",
"difficulty": "medium",
"schema": {
"tables": [
"orders(id, user_id, product_id, amount, status, created_at)",
"products(id, name, category, price, stock)"
]
},
"intent": "Get the most expensive product that has been ordered at least once",
"broken_query": "SELECT * FROM products ORDER BY price DESC WHERE id IN (SELECT product_id FROM orders) LIMIT 1",
"correct_query": "SELECT * FROM products WHERE id IN (SELECT product_id FROM orders) ORDER BY price DESC LIMIT 1",
"error_type": "syntax",
"min_turns_expected": 2,
"clarification_answers": {
"clause order": "WHERE must come before ORDER BY"
}
},
{
"id": "medium_011",
"difficulty": "medium",
"schema": {
"tables": [
"users(id, name, email, age, city, active)",
"orders(id, user_id, product_id, amount, status, created_at)"
]
},
"intent": "Get the average order amount per active user",
"broken_query": "SELECT AVG(amount) FROM orders WHERE user_id IN (SELECT id FROM users WHERE active = 1) GROUP user_id",
"correct_query": "SELECT o.user_id, AVG(o.amount) FROM orders o WHERE o.user_id IN (SELECT id FROM users WHERE active = 1) GROUP BY o.user_id",
"error_type": "syntax",
"min_turns_expected": 2,
"clarification_answers": {}
},
{
"id": "medium_012",
"difficulty": "medium",
"schema": {
"tables": [
"users(id, name, email, age, city, active)",
"orders(id, user_id, product_id, amount, status, created_at)"
]
},
"intent": "List all users with their most recent order date, include users with no orders",
"broken_query": "SELECT u.name, MAX(o.created_at) FROM users u JOIN orders o ON u.id = o.user_id GROUP BY u.name",
"correct_query": "SELECT u.name, MAX(o.created_at) AS last_order FROM users u LEFT JOIN orders o ON u.id = o.user_id GROUP BY u.id, u.name",
"error_type": "join",
"min_turns_expected": 2,
"clarification_answers": {
"include users with no orders": "use LEFT JOIN to keep all users",
"created_at type": "TEXT, ISO date format YYYY-MM-DD"
}
},
{
"id": "medium_013",
"difficulty": "medium",
"schema": {
"tables": [
"orders(id, user_id, product_id, amount, status, created_at)",
"products(id, name, category, price, stock)"
]
},
"intent": "Get each category and number of distinct products ordered",
"broken_query": "SELECT category, COUNT(orders.id) FROM products JOIN orders ON products.id = orders.product_id GROUP BY category",
"correct_query": "SELECT p.category, COUNT(DISTINCT p.id) AS products_ordered FROM products p JOIN orders o ON p.id = o.product_id GROUP BY p.category",
"error_type": "logic",
"min_turns_expected": 2,
"clarification_answers": {
"distinct products": "use COUNT(DISTINCT product_id) to avoid counting same product multiple times"
}
},
{
"id": "medium_014",
"difficulty": "medium",
"schema": {
"tables": [
"users(id, name, email, age, city, active)",
"orders(id, user_id, product_id, amount, status, created_at)"
]
},
"intent": "Get users who placed orders in both January and March 2024",
"broken_query": "SELECT DISTINCT u.name FROM users u JOIN orders o ON u.id = o.user_id WHERE o.created_at LIKE '2024-01%' AND o.created_at LIKE '2024-03%'",
"correct_query": "SELECT u.name FROM users u JOIN orders o1 ON u.id = o1.user_id AND o1.created_at LIKE '2024-01%' JOIN orders o2 ON u.id = o2.user_id AND o2.created_at LIKE '2024-03%'",
"error_type": "logic",
"min_turns_expected": 3,
"clarification_answers": {
"created_at format": "YYYY-MM-DD string",
"how to match both months": "join orders table twice, once per month"
}
},
{
"id": "medium_015",
"difficulty": "medium",
"schema": {
"tables": [
"users(id, name, email, age, city, active)",
"orders(id, user_id, product_id, amount, status, created_at)"
]
},
"intent": "Find users whose total order amount exceeds 400",
"broken_query": "SELECT name FROM users u JOIN orders o ON u.id = o.user_id WHERE SUM(o.amount) > 400",
"correct_query": "SELECT u.name FROM users u JOIN orders o ON u.id = o.user_id GROUP BY u.id, u.name HAVING SUM(o.amount) > 400",
"error_type": "logic",
"min_turns_expected": 2,
"clarification_answers": {
"aggregate in WHERE": "SUM cannot be used in WHERE; use HAVING after GROUP BY"
}
}
]
|