id,template,difficulty,question,gold_sql,answer,answer_rows sq1-0000,top_cust,hard,"List the top 4 customer ids by total spend in cents (qty times price_cents), highest first, ties broken by lower id. Return id and spend.","SELECT o.customer_id, SUM(o.qty*p.price_cents) AS spend FROM orders o JOIN products p ON p.id=o.product_id GROUP BY o.customer_id ORDER BY spend DESC, o.customer_id ASC LIMIT 4;","[[20, 158226], [31, 157905], [22, 135087], [29, 127309]]",4 sq1-0001,joined,easy,How many customers joined before 2025-07-01?,SELECT COUNT(*) FROM customers WHERE joined < '2025-07-01';,[[13]],1 sq1-0002,count_city,easy,How many customers live in Glen?,SELECT COUNT(*) FROM customers WHERE city = 'Glen';,[[9]],1 sq1-0003,count_city,easy,How many customers live in Cedar?,SELECT COUNT(*) FROM customers WHERE city = 'Cedar';,[[4]],1 sq1-0004,city_tier,medium,How many 'free' tier customers live in Avon?,SELECT COUNT(*) FROM customers WHERE city = 'Avon' AND tier = 'free';,[[1]],1 sq1-0005,cust_orders,easy,"List the order ids placed by customer 35, sorted ascending.",SELECT id FROM orders WHERE customer_id = 35 ORDER BY id;,"[[1], [52], [89], [144], [158]]",5 sq1-0006,month,easy,How many orders were placed in 2026-04?,"SELECT COUNT(*) FROM orders WHERE substr(order_date,1,7) = '2026-04';",[[23]],1 sq1-0007,price,easy,"List product ids and price_cents for products priced above 8500 cents, sorted by id.","SELECT id, price_cents FROM products WHERE price_cents > 8500 ORDER BY id;","[[9, 8902], [11, 9892], [21, 9520], [27, 9084], [29, 9373]]",5 sq1-0008,city_qty,medium,What is the total qty ordered by customers in Harbor?,"SELECT COALESCE(SUM(o.qty),0) FROM orders o JOIN customers c ON c.id=o.customer_id WHERE c.city = 'Harbor';",[[72]],1 sq1-0009,rev_cat,medium,What is the total revenue in cents from products in category 'audio' (qty times price_cents)?,"SELECT COALESCE(SUM(o.qty*p.price_cents),0) FROM orders o JOIN products p ON p.id=o.product_id WHERE p.category = 'audio';",[[595389]],1 sq1-0010,city_cat,hard,What total qty of 'kitchen' products was ordered by customers in Brook?,"SELECT COALESCE(SUM(o.qty),0) FROM orders o JOIN customers c ON c.id=o.customer_id JOIN products p ON p.id=o.product_id WHERE c.city = 'Brook' AND p.category = 'kitchen';",[[22]],1 sq1-0011,tier_avg,medium,"What is the average order qty for customers in tier 'pro', rounded to 4 decimals?","SELECT ROUND(AVG(o.qty),4) FROM orders o JOIN customers c ON c.id=o.customer_id WHERE c.tier = 'pro';",[[2.7083]],1 sq1-0012,tier_avg,medium,"What is the average order qty for customers in tier 'free', rounded to 4 decimals?","SELECT ROUND(AVG(o.qty),4) FROM orders o JOIN customers c ON c.id=o.customer_id WHERE c.tier = 'free';",[[2.7222]],1 sq1-0013,price,easy,"List product ids and price_cents for products priced above 5750 cents, sorted by id.","SELECT id, price_cents FROM products WHERE price_cents > 5750 ORDER BY id;","[[1, 8477], [3, 6069], [6, 5955], [9, 8902], [11, 9892], [17, 8483], [21, 9520], [23, 7890], [24, 6986], [26, 7018], [27, 9084], [29, 9373]]",12 sq1-0014,range,medium,"List the ids of orders placed from 2026-07-17 to 2026-07-23 inclusive, sorted ascending.",SELECT id FROM orders WHERE order_date BETWEEN '2026-07-17' AND '2026-07-23' ORDER BY id;,[[194]],1 sq1-0015,city_cat,hard,What total qty of 'audio' products was ordered by customers in Dover?,"SELECT COALESCE(SUM(o.qty),0) FROM orders o JOIN customers c ON c.id=o.customer_id JOIN products p ON p.id=o.product_id WHERE c.city = 'Dover' AND p.category = 'audio';",[[11]],1 sq1-0016,month,easy,How many orders were placed in 2026-05?,"SELECT COUNT(*) FROM orders WHERE substr(order_date,1,7) = '2026-05';",[[26]],1 sq1-0017,count_city,easy,How many customers live in Elm?,SELECT COUNT(*) FROM customers WHERE city = 'Elm';,[[6]],1 sq1-0018,city_qty,medium,What is the total qty ordered by customers in Avon?,"SELECT COALESCE(SUM(o.qty),0) FROM orders o JOIN customers c ON c.id=o.customer_id WHERE c.city = 'Avon';",[[34]],1 sq1-0019,city_qty,medium,What is the total qty ordered by customers in Elm?,"SELECT COALESCE(SUM(o.qty),0) FROM orders o JOIN customers c ON c.id=o.customer_id WHERE c.city = 'Elm';",[[73]],1 sq1-0020,top_cust,hard,"List the top 3 customer ids by total spend in cents (qty times price_cents), highest first, ties broken by lower id. Return id and spend.","SELECT o.customer_id, SUM(o.qty*p.price_cents) AS spend FROM orders o JOIN products p ON p.id=o.product_id GROUP BY o.customer_id ORDER BY spend DESC, o.customer_id ASC LIMIT 3;","[[20, 158226], [31, 157905], [22, 135087]]",3 sq1-0021,city_tier,medium,How many 'plus' tier customers live in Avon?,SELECT COUNT(*) FROM customers WHERE city = 'Avon' AND tier = 'plus';,[[1]],1 sq1-0022,never,hard,Which customer ids never ordered a product in category 'toys'? Sort ascending.,SELECT id FROM customers WHERE id NOT IN (SELECT o.customer_id FROM orders o JOIN products p ON p.id=o.product_id WHERE p.category = 'toys') ORDER BY id;,"[[1], [2], [3], [4], [5], [8], [9], [11], [13], [14], [16], [17], [19], [21], [22], [27], [28], [30], [31], [32], [33], [35], [36], [39], [40]]",25 sq1-0023,month,easy,How many orders were placed in 2026-02?,"SELECT COUNT(*) FROM orders WHERE substr(order_date,1,7) = '2026-02';",[[24]],1 sq1-0024,never,hard,Which customer ids never ordered a product in category 'garden'? Sort ascending.,SELECT id FROM customers WHERE id NOT IN (SELECT o.customer_id FROM orders o JOIN products p ON p.id=o.product_id WHERE p.category = 'garden') ORDER BY id;,"[[3], [6], [7], [11], [13], [14], [15], [17], [18], [20], [23], [24], [25], [26], [27], [36], [37], [39]]",18 sq1-0025,tier_avg,medium,"What is the average order qty for customers in tier 'plus', rounded to 4 decimals?","SELECT ROUND(AVG(o.qty),4) FROM orders o JOIN customers c ON c.id=o.customer_id WHERE c.tier = 'plus';",[[2.96]],1 sq1-0026,rev_cat,medium,What is the total revenue in cents from products in category 'toys' (qty times price_cents)?,"SELECT COALESCE(SUM(o.qty*p.price_cents),0) FROM orders o JOIN products p ON p.id=o.product_id WHERE p.category = 'toys';",[[293504]],1 sq1-0027,cust_orders,easy,"List the order ids placed by customer 24, sorted ascending.",SELECT id FROM orders WHERE customer_id = 24 ORDER BY id;,"[[84], [98], [178], [180]]",4 sq1-0028,city_tier,medium,How many 'plus' tier customers live in Harbor?,SELECT COUNT(*) FROM customers WHERE city = 'Harbor' AND tier = 'plus';,[[1]],1 sq1-0029,cat_distinct,medium,How many distinct customers ordered at least one 'tools' product?,SELECT COUNT(DISTINCT o.customer_id) FROM orders o JOIN products p ON p.id=o.product_id WHERE p.category = 'tools';,[[11]],1