Dataset Viewer
Auto-converted to Parquet Duplicate
id
stringlengths
26
26
schema_id
stringlengths
23
23
domain
stringclasses
50 values
category
stringclasses
6 values
schema_ddl
stringlengths
684
1.81k
seed_inserts
stringlengths
1.37k
8.1k
question
stringlengths
80
526
sql
stringlengths
89
1.87k
alt_verified_sql
stringlengths
54
1.65k
num_result_rows
int64
1
79
dual_verified
bool
1 class
generator_model
stringclasses
1 value
verifier_model
stringclasses
1 value
license
stringclasses
1 value
prism_sql_0000_e2b959aa_q0
prism_sql_0000_e2b959aa
B2B Wholesale Distribution
window_functions
CREATE TABLE distributors ( dist_id INTEGER PRIMARY KEY, name TEXT NOT NULL ); CREATE TABLE retailers ( ret_id INTEGER PRIMARY KEY, name TEXT NOT NULL, dist_id INTEGER, FOREIGN KEY (dist_id) REFERENCES distributors(dist_id) ); CREATE TABLE skus ( sku_id INTEGER PRIMARY KEY, name TEXT N...
INSERT INTO distributors (dist_id, name) VALUES (1, 'Northwest Distributors'), (2, 'Southern Supply Co'), (3, 'Eastern Wholesale'), (4, 'Central Hub'); INSERT INTO retailers (ret_id, name, dist_id) VALUES (10, 'Retail A', 1), (11, 'Retail B', 1), (12, 'Retail C', 2), (13, 'Retail D', 2), (14, 'Retail E', 3), (15, 'Ret...
List the top 10 retailers by total spend (quantity * unit_price) across all years. Return retailer name, total_spend rounded to 2 decimals, and the rank (1 = highest spend). Order by rank ascending.
WITH retailer_spend AS ( SELECT r.name AS retailer_name, ROUND(SUM(o.quantity * o.unit_price), 2) AS total_spend FROM retailers r JOIN orders o ON r.ret_id = o.ret_id GROUP BY r.ret_id ) SELECT retailer_name, total_spend, ROW_NUMBER() OVER (ORDER BY total_spend DESC) AS rank FRO...
WITH retailer_spend AS ( SELECT r.name AS retailer_name, ROUND(SUM(o.quantity * o.unit_price), 2) AS total_spend FROM orders o JOIN retailers r ON o.ret_id = r.ret_id GROUP BY r.ret_id, r.name ), ranked AS ( SELECT retailer_name, total_spend, RANK() OVER (OR...
9
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0000_e2b959aa_q2
prism_sql_0000_e2b959aa
B2B Wholesale Distribution
cte_multi_step
CREATE TABLE distributors ( dist_id INTEGER PRIMARY KEY, name TEXT NOT NULL ); CREATE TABLE retailers ( ret_id INTEGER PRIMARY KEY, name TEXT NOT NULL, dist_id INTEGER, FOREIGN KEY (dist_id) REFERENCES distributors(dist_id) ); CREATE TABLE skus ( sku_id INTEGER PRIMARY KEY, name TEXT N...
INSERT INTO distributors (dist_id, name) VALUES (1, 'Northwest Distributors'), (2, 'Southern Supply Co'), (3, 'Eastern Wholesale'), (4, 'Central Hub'); INSERT INTO retailers (ret_id, name, dist_id) VALUES (10, 'Retail A', 1), (11, 'Retail B', 1), (12, 'Retail C', 2), (13, 'Retail D', 2), (14, 'Retail E', 3), (15, 'Ret...
Identify SKUs whose total sales amount grew by at least 20% from 2022 to 2023. Return sku name, sales_2022, sales_2023, and growth_pct (rounded to 2 decimals) where growth_pct = (sales_2023 - sales_2022) / sales_2022 * 100. Order by growth_pct descending.
WITH sales_by_year AS ( SELECT s.sku_id, s.name AS sku_name, strftime('%Y', o.order_date) AS yr, SUM(o.quantity * o.unit_price) AS sales FROM orders o JOIN skus s ON o.sku_id = s.sku_id WHERE strftime('%Y', o.order_date) IN ('2022','2023') GROUP BY s.sku_id, yr ), pi...
SELECT s.name AS sku_name, SUM(CASE WHEN strftime('%Y', o.order_date) = '2022' THEN o.quantity * o.unit_price ELSE 0 END) AS sales_2022, SUM(CASE WHEN strftime('%Y', o.order_date) = '2023' THEN o.quantity * o.unit_price ELSE 0 END) AS sales_2023, ROUND((SUM(CASE WHEN strftime('%Y', o.order_date) = '2023' THEN o.quantit...
5
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0000_e2b959aa_q3
prism_sql_0000_e2b959aa
B2B Wholesale Distribution
set_operations
CREATE TABLE distributors ( dist_id INTEGER PRIMARY KEY, name TEXT NOT NULL ); CREATE TABLE retailers ( ret_id INTEGER PRIMARY KEY, name TEXT NOT NULL, dist_id INTEGER, FOREIGN KEY (dist_id) REFERENCES distributors(dist_id) ); CREATE TABLE skus ( sku_id INTEGER PRIMARY KEY, name TEXT N...
INSERT INTO distributors (dist_id, name) VALUES (1, 'Northwest Distributors'), (2, 'Southern Supply Co'), (3, 'Eastern Wholesale'), (4, 'Central Hub'); INSERT INTO retailers (ret_id, name, dist_id) VALUES (10, 'Retail A', 1), (11, 'Retail B', 1), (12, 'Retail C', 2), (13, 'Retail D', 2), (14, 'Retail E', 3), (15, 'Ret...
Return the names of retailers that placed at least one order in 2023 but never had an order whose order_date fell within a rebate period for the ordered SKU. Order the retailer names alphabetically.
SELECT DISTINCT r.name FROM retailers r JOIN orders o ON r.ret_id = o.ret_id WHERE strftime('%Y', o.order_date) = '2023' EXCEPT SELECT DISTINCT r.name FROM retailers r JOIN orders o ON r.ret_id = o.ret_id JOIN rebates rb ON o.sku_id = rb.sku_id WHERE o.order_date BETWEEN rb.start_date AND rb.end_date;
SELECT DISTINCT r.name FROM retailers r JOIN orders o ON r.ret_id = o.ret_id WHERE o.order_date >= '2023-01-01' AND o.order_date <= '2023-12-31' AND r.ret_id NOT IN ( SELECT o2.ret_id FROM orders o2 JOIN rebates rb ON o2.sku_id = rb.sku_id WHERE o2.order_date >= rb.start_date AND o2.order_date <= rb.end...
2
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0000_e2b959aa_q5
prism_sql_0000_e2b959aa
B2B Wholesale Distribution
complex_aggregation
CREATE TABLE distributors ( dist_id INTEGER PRIMARY KEY, name TEXT NOT NULL ); CREATE TABLE retailers ( ret_id INTEGER PRIMARY KEY, name TEXT NOT NULL, dist_id INTEGER, FOREIGN KEY (dist_id) REFERENCES distributors(dist_id) ); CREATE TABLE skus ( sku_id INTEGER PRIMARY KEY, name TEXT N...
INSERT INTO distributors (dist_id, name) VALUES (1, 'Northwest Distributors'), (2, 'Southern Supply Co'), (3, 'Eastern Wholesale'), (4, 'Central Hub'); INSERT INTO retailers (ret_id, name, dist_id) VALUES (10, 'Retail A', 1), (11, 'Retail B', 1), (12, 'Retail C', 2), (13, 'Retail D', 2), (14, 'Retail E', 3), (15, 'Ret...
Compute each retailer's total spend (rounded to 2 decimals) and the cumulative percentage of total company spend when retailers are ordered by their total spend descending. Return retailer name, total_spend, cumulative_pct rounded to 2 decimals, and a flag column where the value is 'Top10Pct' if cumulative_pct <= 10 el...
WITH total_by_retailer AS ( SELECT r.ret_id, r.name AS retailer_name, ROUND(SUM(o.quantity * o.unit_price), 2) AS total_spend FROM retailers r JOIN orders o ON r.ret_id = o.ret_id GROUP BY r.ret_id ), company_total AS ( SELECT SUM(total_spend) AS company_spend FROM total_by_ret...
WITH retailer_spend AS ( SELECT r.name AS retailer_name, ROUND(SUM(o.quantity * o.unit_price), 2) AS total_spend FROM retailers r JOIN orders o ON r.ret_id = o.ret_id GROUP BY r.ret_id, r.name ), total_company_spend AS ( SELECT SUM(total_spend) AS grand_total FROM retailer_spend ...
9
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0001_0c0e2889_q1
prism_sql_0001_0c0e2889
Agricultural Smart Farming
multiple_joins
CREATE TABLE farms (farm_id INTEGER PRIMARY KEY, farm_name TEXT NOT NULL, region TEXT NOT NULL); CREATE TABLE fields (field_id INTEGER PRIMARY KEY, farm_id INTEGER NOT NULL, field_name TEXT NOT NULL, area_ha REAL NOT NULL, FOREIGN KEY (farm_id) REFERENCES farms(farm_id)); CREATE TABLE sensors (sensor_id INTEGER PRIMARY...
INSERT INTO farms (farm_id, farm_name, region) VALUES (1, 'Green Valley', 'North'), (2, 'Sunny Acres', 'South'), (3, 'Riverbend', 'East'), (4, 'Hilltop', 'West'); INSERT INTO fields (field_id, farm_id, field_name, area_ha) VALUES (1, 1, 'North Field', 12.5), (2, 1, 'East Meadow', 8.3), (3, 2, 'South Plot', 15.0), (4, 2...
Return the harvest_id, farm_name, field_name, crop_type, and yield_tons for all harvests where the field has at least one nitrogen sensor installed before 2022-06-01. Order by harvest_date descending.
SELECT h.harvest_id, fa.farm_name, fl.field_name, h.crop_type, h.yield_tons FROM harvests h JOIN fields fl ON h.field_id = fl.field_id JOIN farms fa ON fl.farm_id = fa.farm_id WHERE EXISTS ( SELECT 1 FROM sensors s WHERE s.field_id = fl.field_id AND s.sensor_type = 'nitrogen' AND s.install_date < '2...
SELECT h.harvest_id, f.farm_name, fi.field_name, h.crop_type, h.yield_tons FROM harvests h JOIN fields fi ON h.field_id = fi.field_id JOIN farms f ON fi.farm_id = f.farm_id WHERE fi.field_id IN (SELECT s.field_id FROM sensors s WHERE s.sensor_type = 'nitrogen' AND s.install_date < '2022-06-01') ORDER BY h.harvest_date ...
4
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0001_0c0e2889_q5
prism_sql_0001_0c0e2889
Agricultural Smart Farming
complex_aggregation
CREATE TABLE farms (farm_id INTEGER PRIMARY KEY, farm_name TEXT NOT NULL, region TEXT NOT NULL); CREATE TABLE fields (field_id INTEGER PRIMARY KEY, farm_id INTEGER NOT NULL, field_name TEXT NOT NULL, area_ha REAL NOT NULL, FOREIGN KEY (farm_id) REFERENCES farms(farm_id)); CREATE TABLE sensors (sensor_id INTEGER PRIMARY...
INSERT INTO farms (farm_id, farm_name, region) VALUES (1, 'Green Valley', 'North'), (2, 'Sunny Acres', 'South'), (3, 'Riverbend', 'East'), (4, 'Hilltop', 'West'); INSERT INTO fields (field_id, farm_id, field_name, area_ha) VALUES (1, 1, 'North Field', 12.5), (2, 1, 'East Meadow', 8.3), (3, 2, 'South Plot', 15.0), (4, 2...
For each sensor_type, compute the total number of readings in 2023, the average nitrogen_ppm (rounded to 2 decimals) for nitrogen sensors, and the maximum moisture_pct (rounded to 1 decimal) for moisture sensors. Present sensor_type, reading_count, avg_nitrogen_ppm (null if not applicable), max_moisture_pct (null if no...
SELECT s.sensor_type, COUNT(r.reading_id) AS reading_count, ROUND(AVG(CASE WHEN s.sensor_type = 'nitrogen' THEN r.nitrogen_ppm END), 2) AS avg_nitrogen_ppm, ROUND(MAX(CASE WHEN s.sensor_type = 'moisture' THEN r.moisture_pct END), 1) AS max_moisture_pct FROM sensors s JOIN soil_readings r ON s.senso...
SELECT s.sensor_type, COUNT(sr.reading_id) AS reading_count, CASE WHEN s.sensor_type = 'nitrogen' THEN ROUND(AVG(sr.nitrogen_ppm), 2) ELSE NULL END AS avg_nitrogen_ppm, CASE WHEN s.sensor_type = 'moisture' THEN ROUND(MAX(sr.moisture_pct), 1) ELSE NULL END AS max_moisture_pct FROM sensors s J...
2
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0002_d2cefee0_q3
prism_sql_0002_d2cefee0
Subscription Meal-Kit Ops
set_operations
CREATE TABLE subscribers ( subscriber_id INTEGER PRIMARY KEY, name TEXT NOT NULL, signup_date TEXT NOT NULL ); CREATE TABLE recipes ( recipe_id INTEGER PRIMARY KEY, name TEXT NOT NULL, season TEXT NOT NULL CHECK (season IN ("Winter","Spring","Summer","Fall")) ); CREATE TABLE ingredients ( ...
INSERT INTO subscribers (subscriber_id, name, signup_date) VALUES (1, 'Alice Johnson', '2022-11-15'), (2, 'Bob Smith', '2023-01-02'), (3, 'Carol Lee', '2023-02-20'), (4, 'David Kim', '2022-12-05'), (5, 'Eva Patel', '2023-03-10'), (6, 'Frank Wu', '2023-01-25'), (7, 'Grace Chen', '2023-04-01'), (8, 'Hank Miller', '2023-0...
List the names of subscribers who have received at least one box in both the Winter season (box months Dec‑Feb) and the Summer season (box months Jun‑Aug). Use a set operation to find the intersection. Order the names alphabetically.
SELECT name FROM ( SELECT s.subscriber_id, s.name FROM subscribers s JOIN boxes b ON s.subscriber_id = b.subscriber_id WHERE strftime('%m', b.box_date) IN ('12','01','02') GROUP BY s.subscriber_id ) INTERSECT SELECT name FROM ( SELECT s.subscriber_id, s.name FROM subscribers s JOIN boxes...
SELECT s.name FROM subscribers s JOIN boxes b1 ON s.subscriber_id = b1.subscriber_id WHERE CAST(SUBSTR(b1.box_date, 6, 2) AS INTEGER) IN (12, 1, 2) INTERSECT SELECT s.name FROM subscribers s JOIN boxes b2 ON s.subscriber_id = b2.subscriber_id WHERE CAST(SUBSTR(b2.box_date, 6, 2) AS INTEGER) IN (6, 7, 8) ORDER BY s.name...
1
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0002_d2cefee0_q5
prism_sql_0002_d2cefee0
Subscription Meal-Kit Ops
complex_aggregation
CREATE TABLE subscribers ( subscriber_id INTEGER PRIMARY KEY, name TEXT NOT NULL, signup_date TEXT NOT NULL ); CREATE TABLE recipes ( recipe_id INTEGER PRIMARY KEY, name TEXT NOT NULL, season TEXT NOT NULL CHECK (season IN ("Winter","Spring","Summer","Fall")) ); CREATE TABLE ingredients ( ...
INSERT INTO subscribers (subscriber_id, name, signup_date) VALUES (1, 'Alice Johnson', '2022-11-15'), (2, 'Bob Smith', '2023-01-02'), (3, 'Carol Lee', '2023-02-20'), (4, 'David Kim', '2022-12-05'), (5, 'Eva Patel', '2023-03-10'), (6, 'Frank Wu', '2023-01-25'), (7, 'Grace Chen', '2023-04-01'), (8, 'Hank Miller', '2023-0...
For each ingredient category, compute the average number of that ingredient's occurrences per box (i.e., total quantity of box items whose recipes include the ingredient divided by the number of distinct boxes that contain at least one such recipe). Round the average to two decimal places. Return category and avg_occur...
SELECT i.category, ROUND( CAST(SUM(bi.quantity) AS REAL) / COUNT(DISTINCT b.box_id), 2) AS avg_occurrences FROM box_items bi JOIN boxes b ON bi.box_id = b.box_id JOIN recipes r ON bi.recipe_id = r.recipe_id JOIN recipe_ingredients ri ON r.recipe_id = ri.recipe_id JOIN ingredients i ON ri.ingredient_id = i.ingre...
SELECT i.category, ROUND( CAST(SUM(bi.quantity) AS REAL) / COUNT(DISTINCT bi.box_id), 2 ) AS avg_occurrences FROM box_items bi JOIN recipes r ON bi.recipe_id = r.recipe_id JOIN recipe_ingredients ri ON r.recipe_id = ri.recipe_id JOIN ingredients i ON ri.ingredient_id = i.ingr...
5
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0004_19bcb2fa_q1
prism_sql_0004_19bcb2fa
FinTech Digital Banking Ledger
multiple_joins
CREATE TABLE customers ( customer_id INTEGER PRIMARY KEY, name TEXT NOT NULL, country TEXT NOT NULL, signup_date TEXT NOT NULL -- stored as ISO date ); CREATE TABLE accounts ( account_id INTEGER PRIMARY KEY, customer_id INTEGER NOT NULL, account_type TEXT NOT NULL CHECK(account_type IN ('ch...
INSERT INTO customers (customer_id,name,country,signup_date) VALUES (1,'Alice Smith','US','2021-03-15'), (2,'Bob Jones','GB','2020-11-02'), (3,'Carlos Ruiz','MX','2022-01-20'), (4,'Diana Lee','CA','2021-07-08'), (5,'Ethan Patel','US','2020-05-30'); INSERT INTO accounts (account_id,customer_id,account_type,currency,ope...
Retrieve the transaction_id, transaction date, amount, merchant, account_type, and customer country for all payments (txn_type='payment') made in June 2022 where the customer country is not 'US'. Order by transaction_id ascending.
SELECT t.transaction_id, t.txn_date, t.amount, t.merchant, a.account_type, c.country FROM transactions t JOIN accounts a ON t.account_id = a.account_id JOIN customers c ON a.customer_id = c.customer_id WHERE t.txn_type = 'payment' AND substr(t.txn_date,1,7) = '2022-06' AND c.count...
SELECT t.transaction_id, t.txn_date, t.amount, t.merchant, a.account_type, c.country FROM transactions t JOIN accounts a ON t.account_id = a.account_id JOIN customers c ON a.customer_id = c.customer_id WHERE t.txn_type = 'payment' AND c.country != 'US' AND t.txn_date >= '2022-06-01' AND t.txn_date < '2022-07-01' ORDER ...
3
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0004_19bcb2fa_q2
prism_sql_0004_19bcb2fa
FinTech Digital Banking Ledger
cte_multi_step
CREATE TABLE customers ( customer_id INTEGER PRIMARY KEY, name TEXT NOT NULL, country TEXT NOT NULL, signup_date TEXT NOT NULL -- stored as ISO date ); CREATE TABLE accounts ( account_id INTEGER PRIMARY KEY, customer_id INTEGER NOT NULL, account_type TEXT NOT NULL CHECK(account_type IN ('ch...
INSERT INTO customers (customer_id,name,country,signup_date) VALUES (1,'Alice Smith','US','2021-03-15'), (2,'Bob Jones','GB','2020-11-02'), (3,'Carlos Ruiz','MX','2022-01-20'), (4,'Diana Lee','CA','2021-07-08'), (5,'Ethan Patel','US','2020-05-30'); INSERT INTO accounts (account_id,customer_id,account_type,currency,ope...
Using CTEs, first compute the total transferred amount per originating account for completed transfers, then list the account_id, total_transferred, and account status for accounts whose total transferred exceeds 400, ordered by total_transferred descending.
WITH transfer_sums AS ( SELECT from_account_id AS account_id, SUM(amount) AS total_transferred FROM transfers WHERE status = 'completed' GROUP BY from_account_id ) SELECT ts.account_id, ts.total_transferred, a.status FROM transfer_sums ts JOIN accounts a ON ts.account_id = a.acc...
WITH transferred_per_account AS ( SELECT from_account_id AS account_id, SUM(amount) AS total_transferred FROM transfers WHERE status = 'completed' GROUP BY from_account_id ) SELECT t.account_id, t.total_transferred, a.status FROM transferred_per_account t JOIN accounts a ON t...
1
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0005_c724051c_q0
prism_sql_0005_c724051c
Ride-Sharing Fleet Dispatch
window_functions
CREATE TABLE drivers ( driver_id INTEGER PRIMARY KEY, name TEXT NOT NULL, rating REAL NOT NULL, vehicle_id INTEGER, FOREIGN KEY (vehicle_id) REFERENCES vehicles(vehicle_id) ); CREATE TABLE riders ( rider_id INTEGER PRIMARY KEY, name TEXT NOT NULL, signup_date TEXT NOT NULL -- stored as ...
INSERT INTO vehicles (vehicle_id, make, model, year, capacity) VALUES (1, 'Toyota', 'Camry', 2018, 4), (2, 'Honda', 'Civic', 2020, 4), (3, 'Ford', 'Transit', 2019, 8), (4, 'Tesla', 'Model 3', 2021, 4), (5, 'Chevrolet', 'Bolt', 2022, 4); INSERT INTO drivers (driver_id, name, rating, vehicle_id) VALUES (101, 'Alice', 4....
List each driver_id with their total fare earned, their rank based on total fare (1 = highest), and the cumulative fare up to that driver, ordered by rank ascending. If two drivers have the same total fare, assign the same rank and order them by driver_id ascending.
WITH driver_totals AS ( SELECT d.driver_id, SUM(t.fare) AS total_fare FROM drivers d JOIN trips t ON d.driver_id = t.driver_id GROUP BY d.driver_id ) SELECT driver_id, total_fare, RANK() OVER (ORDER BY total_fare DESC) AS fare_rank, SUM(total_fare) OVER (ORDER BY total_fa...
WITH driver_totals AS ( SELECT driver_id, SUM(fare) AS total_fare FROM trips GROUP BY driver_id ), ranked AS ( SELECT driver_id, total_fare, RANK() OVER (ORDER BY total_fare DESC) AS rnk, SUM(total_fare) OVER (ORDER BY total_fare DESC, driver_id ASC ROWS U...
5
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0005_c724051c_q1
prism_sql_0005_c724051c
Ride-Sharing Fleet Dispatch
multiple_joins
CREATE TABLE drivers ( driver_id INTEGER PRIMARY KEY, name TEXT NOT NULL, rating REAL NOT NULL, vehicle_id INTEGER, FOREIGN KEY (vehicle_id) REFERENCES vehicles(vehicle_id) ); CREATE TABLE riders ( rider_id INTEGER PRIMARY KEY, name TEXT NOT NULL, signup_date TEXT NOT NULL -- stored as ...
INSERT INTO vehicles (vehicle_id, make, model, year, capacity) VALUES (1, 'Toyota', 'Camry', 2018, 4), (2, 'Honda', 'Civic', 2020, 4), (3, 'Ford', 'Transit', 2019, 8), (4, 'Tesla', 'Model 3', 2021, 4), (5, 'Chevrolet', 'Bolt', 2022, 4); INSERT INTO drivers (driver_id, name, rating, vehicle_id) VALUES (101, 'Alice', 4....
Return rider_id, rider name, driver name, vehicle make, and fare for all trips that occurred in the 'Airport' surge zone, ordered by fare descending then rider_id ascending.
SELECT r.rider_id, r.name AS rider_name, d.name AS driver_name, v.make AS vehicle_make, t.fare FROM trips t JOIN riders r ON t.rider_id = r.rider_id JOIN drivers d ON t.driver_id = d.driver_id JOIN vehicles v ON t.vehicle_id = v.vehicle_id JOIN surge_zones sz ON t.zone_id = sz.zone_id WHERE ...
SELECT t.rider_id, r.name AS rider_name, d.name AS driver_name, v.make, t.fare FROM trips t JOIN riders r ON t.rider_id = r.rider_id JOIN drivers d ON t.driver_id = d.driver_id JOIN vehicles v ON t.vehicle_id = v.vehicle_id JOIN surge_zones sz ON t.zone_id = sz.zone_id WHERE sz.zone_name = 'Airport' ORDER BY t.fare DES...
8
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0005_c724051c_q2
prism_sql_0005_c724051c
Ride-Sharing Fleet Dispatch
cte_multi_step
CREATE TABLE drivers ( driver_id INTEGER PRIMARY KEY, name TEXT NOT NULL, rating REAL NOT NULL, vehicle_id INTEGER, FOREIGN KEY (vehicle_id) REFERENCES vehicles(vehicle_id) ); CREATE TABLE riders ( rider_id INTEGER PRIMARY KEY, name TEXT NOT NULL, signup_date TEXT NOT NULL -- stored as ...
INSERT INTO vehicles (vehicle_id, make, model, year, capacity) VALUES (1, 'Toyota', 'Camry', 2018, 4), (2, 'Honda', 'Civic', 2020, 4), (3, 'Ford', 'Transit', 2019, 8), (4, 'Tesla', 'Model 3', 2021, 4), (5, 'Chevrolet', 'Bolt', 2022, 4); INSERT INTO drivers (driver_id, name, rating, vehicle_id) VALUES (101, 'Alice', 4....
Find the top 3 drivers with the highest average fare per trip (average rounded to 2 decimals). For each of these drivers, list driver_id, driver name, average_fare, and the number of trips they completed in surge zones with multiplier >= 1.5. Order by average_fare descending.
WITH avg_fare AS ( SELECT d.driver_id, d.name, ROUND(AVG(t.fare), 2) AS avg_fare, COUNT(*) AS trip_cnt FROM drivers d JOIN trips t ON d.driver_id = t.driver_id GROUP BY d.driver_id ), top3 AS ( SELECT driver_id, name, avg_fare, trip_cnt FROM avg_fare ORDER BY...
SELECT d.driver_id, d.name, ROUND(AVG(t.fare), 2) AS average_fare, SUM(CASE WHEN t.zone_id IS NOT NULL AND sz.surge_multiplier >= 1.5 THEN 1 ELSE 0 END) AS surge_trips FROM drivers d JOIN trips t ON d.driver_id = t.driver_id LEFT JOIN surge_zones sz ON t.zone_id = sz.zone_id GROUP BY d.driver_id, d.name ORDER BY averag...
3
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0005_c724051c_q3
prism_sql_0005_c724051c
Ride-Sharing Fleet Dispatch
set_operations
CREATE TABLE drivers ( driver_id INTEGER PRIMARY KEY, name TEXT NOT NULL, rating REAL NOT NULL, vehicle_id INTEGER, FOREIGN KEY (vehicle_id) REFERENCES vehicles(vehicle_id) ); CREATE TABLE riders ( rider_id INTEGER PRIMARY KEY, name TEXT NOT NULL, signup_date TEXT NOT NULL -- stored as ...
INSERT INTO vehicles (vehicle_id, make, model, year, capacity) VALUES (1, 'Toyota', 'Camry', 2018, 4), (2, 'Honda', 'Civic', 2020, 4), (3, 'Ford', 'Transit', 2019, 8), (4, 'Tesla', 'Model 3', 2021, 4), (5, 'Chevrolet', 'Bolt', 2022, 4); INSERT INTO drivers (driver_id, name, rating, vehicle_id) VALUES (101, 'Alice', 4....
List rider_id and name of riders who have taken at least one trip in a surge zone AND also have taken at least one trip outside any surge zone. Use UNION to also include riders who have never taken any trip at all. Order the result by rider_id ascending.
SELECT DISTINCT r.rider_id, r.name FROM riders r JOIN trips t ON r.rider_id = t.rider_id JOIN surge_zones sz ON t.zone_id = sz.zone_id WHERE sz.zone_id IS NOT NULL INTERSECT SELECT DISTINCT r.rider_id, r.name FROM riders r JOIN trips t ON r.rider_id = t.rider_id WHERE t.zone_id IS NULL UNION SELECT r.rider_id, r.name F...
SELECT rider_id, name FROM riders WHERE rider_id IN (SELECT rider_id FROM trips WHERE zone_id IS NOT NULL) AND rider_id IN (SELECT rider_id FROM trips WHERE zone_id IS NULL) UNION SELECT rider_id, name FROM riders WHERE rider_id NOT IN (SELECT rider_id FROM trips) ORDER BY rider_id ASC
6
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0005_c724051c_q4
prism_sql_0005_c724051c
Ride-Sharing Fleet Dispatch
correlated_subqueries
CREATE TABLE drivers ( driver_id INTEGER PRIMARY KEY, name TEXT NOT NULL, rating REAL NOT NULL, vehicle_id INTEGER, FOREIGN KEY (vehicle_id) REFERENCES vehicles(vehicle_id) ); CREATE TABLE riders ( rider_id INTEGER PRIMARY KEY, name TEXT NOT NULL, signup_date TEXT NOT NULL -- stored as ...
INSERT INTO vehicles (vehicle_id, make, model, year, capacity) VALUES (1, 'Toyota', 'Camry', 2018, 4), (2, 'Honda', 'Civic', 2020, 4), (3, 'Ford', 'Transit', 2019, 8), (4, 'Tesla', 'Model 3', 2021, 4), (5, 'Chevrolet', 'Bolt', 2022, 4); INSERT INTO drivers (driver_id, name, rating, vehicle_id) VALUES (101, 'Alice', 4....
For each driver, show driver_id, driver name, and the fare of their most expensive trip. If the driver has no trips, show NULL for the fare. Order by driver_id ascending.
SELECT d.driver_id, d.name, (SELECT MAX(t.fare) FROM trips t WHERE t.driver_id = d.driver_id) AS max_fare FROM drivers d ORDER BY d.driver_id ASC;
SELECT d.driver_id, d.name, MAX(t.fare) AS fare FROM drivers d LEFT JOIN trips t ON d.driver_id = t.driver_id GROUP BY d.driver_id, d.name ORDER BY d.driver_id ASC;
6
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0005_c724051c_q5
prism_sql_0005_c724051c
Ride-Sharing Fleet Dispatch
complex_aggregation
CREATE TABLE drivers ( driver_id INTEGER PRIMARY KEY, name TEXT NOT NULL, rating REAL NOT NULL, vehicle_id INTEGER, FOREIGN KEY (vehicle_id) REFERENCES vehicles(vehicle_id) ); CREATE TABLE riders ( rider_id INTEGER PRIMARY KEY, name TEXT NOT NULL, signup_date TEXT NOT NULL -- stored as ...
INSERT INTO vehicles (vehicle_id, make, model, year, capacity) VALUES (1, 'Toyota', 'Camry', 2018, 4), (2, 'Honda', 'Civic', 2020, 4), (3, 'Ford', 'Transit', 2019, 8), (4, 'Tesla', 'Model 3', 2021, 4), (5, 'Chevrolet', 'Bolt', 2022, 4); INSERT INTO drivers (driver_id, name, rating, vehicle_id) VALUES (101, 'Alice', 4....
Compute, for each month in 2022, the total number of trips, total distance (rounded to 1 decimal), average fare (rounded to 2 decimals), and the percentage of trips that occurred in a surge zone (rounded to 2 decimals). Return month in 'YYYY-MM' format, sorted chronologically.
SELECT strftime('%Y-%m', t.start_time) AS month, COUNT(*) AS trip_count, ROUND(SUM(t.distance_km), 1) AS total_distance, ROUND(AVG(t.fare), 2) AS avg_fare, ROUND(100.0 * SUM(CASE WHEN t.zone_id IS NOT NULL THEN 1 ELSE 0 END) / COUNT(*), 2) AS surge_trip_pct FROM trips t WHERE strftime('%Y', ...
SELECT strftime('%Y-%m', start_time) AS month, COUNT(*) AS total_trips, ROUND(SUM(distance_km), 1) AS total_distance, ROUND(AVG(fare), 2) AS average_fare, ROUND(100.0 * SUM(CASE WHEN zone_id IS NOT NULL THEN 1 ELSE 0 END) / COUNT(*), 2) AS surge_zone_percentage FROM trips WHERE start_time >= '2022-0...
2
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0006_bf35fc36_q1
prism_sql_0006_bf35fc36
Global Supply Chain & Warehousing
multiple_joins
CREATE TABLE suppliers ( supplier_id INTEGER PRIMARY KEY, supplier_name TEXT NOT NULL, country TEXT NOT NULL ); CREATE TABLE warehouses ( warehouse_id INTEGER PRIMARY KEY, warehouse_name TEXT NOT NULL, region TEXT NOT NULL ); CREATE TABLE products ( product_id INTEGER PRIMARY KEY, prod...
INSERT INTO suppliers (supplier_id, supplier_name, country) VALUES (1, 'Alpha Metals', 'USA'), (2, 'Beta Plastics', 'Germany'), (3, 'Gamma Textiles', 'China'), (4, 'Delta Electronics', 'Japan'), (5, 'Epsilon Foods', 'Mexico'); INSERT INTO warehouses (warehouse_id, warehouse_name, region) VALUES (1, 'North Hub', 'North...
Return the supplier_name, product_name, warehouse_name, and move_date for all IN moves that occurred in March 2023, ordered by move_date ascending.
SELECT s.supplier_name, p.product_name, w.warehouse_name, im.move_date FROM inventory_moves im JOIN purchase_orders po ON im.po_id = po.po_id JOIN suppliers s ON po.supplier_id = s.supplier_id JOIN products p ON po.product_id = p.product_id JOIN warehouses w ON im.warehouse_id = w.warehouse_id WHER...
SELECT s.supplier_name, p.product_name, w.warehouse_name, im.move_date FROM inventory_moves im JOIN purchase_orders po ON im.po_id = po.po_id JOIN suppliers s ON po.supplier_id = s.supplier_id JOIN products p ON po.product_id = p.product_id JOIN warehouses w ON im.warehouse_id = w.warehouse_id WHERE im.move_type = 'IN'...
1
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0006_bf35fc36_q4
prism_sql_0006_bf35fc36
Global Supply Chain & Warehousing
correlated_subqueries
CREATE TABLE suppliers ( supplier_id INTEGER PRIMARY KEY, supplier_name TEXT NOT NULL, country TEXT NOT NULL ); CREATE TABLE warehouses ( warehouse_id INTEGER PRIMARY KEY, warehouse_name TEXT NOT NULL, region TEXT NOT NULL ); CREATE TABLE products ( product_id INTEGER PRIMARY KEY, prod...
INSERT INTO suppliers (supplier_id, supplier_name, country) VALUES (1, 'Alpha Metals', 'USA'), (2, 'Beta Plastics', 'Germany'), (3, 'Gamma Textiles', 'China'), (4, 'Delta Electronics', 'Japan'), (5, 'Epsilon Foods', 'Mexico'); INSERT INTO warehouses (warehouse_id, warehouse_name, region) VALUES (1, 'North Hub', 'North...
For each supplier, show supplier_name and the total value (quantity * unit_price) of purchase orders placed in 2022 that have at least one corresponding IN inventory move, ordered by total_value descending.
SELECT s.supplier_name, (SELECT ROUND(SUM(po.quantity * po.unit_price), 2) FROM purchase_orders po WHERE po.supplier_id = s.supplier_id AND substr(po.order_date,1,4) = '2022' AND EXISTS (SELECT 1 FROM inventory_moves im WHERE im.po_id = po.po_id AND im.move_type = 'IN') ...
SELECT s.supplier_name, SUM(po.quantity * po.unit_price) AS total_value FROM suppliers s JOIN purchase_orders po ON s.supplier_id = po.supplier_id WHERE po.order_date >= '2022-01-01' AND po.order_date < '2023-01-01' AND EXISTS (SELECT 1 FROM inventory_moves im WHERE im.po_id = po.po_id AND im.move_type = 'IN') GROUP BY...
5
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0006_bf35fc36_q5
prism_sql_0006_bf35fc36
Global Supply Chain & Warehousing
complex_aggregation
CREATE TABLE suppliers ( supplier_id INTEGER PRIMARY KEY, supplier_name TEXT NOT NULL, country TEXT NOT NULL ); CREATE TABLE warehouses ( warehouse_id INTEGER PRIMARY KEY, warehouse_name TEXT NOT NULL, region TEXT NOT NULL ); CREATE TABLE products ( product_id INTEGER PRIMARY KEY, prod...
INSERT INTO suppliers (supplier_id, supplier_name, country) VALUES (1, 'Alpha Metals', 'USA'), (2, 'Beta Plastics', 'Germany'), (3, 'Gamma Textiles', 'China'), (4, 'Delta Electronics', 'Japan'), (5, 'Epsilon Foods', 'Mexico'); INSERT INTO warehouses (warehouse_id, warehouse_name, region) VALUES (1, 'North Hub', 'North...
For each month in 2023, compute the average unit price of purchase orders (rounded to 2 decimals) and the total weight shipped IN (quantity * unit_weight) that month across all warehouses, and return month (YYYY-MM), avg_unit_price, total_in_weight, ordered by month ascending.
WITH po_month AS ( SELECT substr(po.order_date,1,7) AS month, po.unit_price, po.quantity, p.unit_weight FROM purchase_orders po JOIN products p ON po.product_id = p.product_id WHERE substr(po.order_date,1,4) = '2023' ), in_moves AS ( SELECT substr(im.move_date,1,7) A...
SELECT strftime('%Y-%m', po.order_date) AS month, ROUND(AVG(po.unit_price), 2) AS avg_unit_price, SUM(im.quantity * p.unit_weight) AS total_in_weight FROM purchase_orders po JOIN products p ON po.product_id = p.product_id JOIN inventory_moves im ON po.po_id = im.po_id WHERE im.move_type = 'IN' AND po.orde...
7
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0008_4803a849_q0
prism_sql_0008_4803a849
Enterprise HR & Payroll
window_functions
CREATE TABLE departments ( dept_id INTEGER PRIMARY KEY, dept_name TEXT NOT NULL, location TEXT ); CREATE TABLE employees ( emp_id INTEGER PRIMARY KEY, first_name TEXT NOT NULL, last_name TEXT NOT NULL, dept_id INTEGER NOT NULL, hire_date TEXT NOT NULL, -- ISO date gender TEXT CHECK(...
INSERT INTO departments (dept_id, dept_name, location) VALUES (1, 'Engineering', 'New York'), (2, 'Human Resources', 'Chicago'), (3, 'Marketing', 'San Francisco'), (4, 'Finance', 'Boston'), (5, 'Legal', 'Washington'); INSERT INTO employees (emp_id, first_name, last_name, dept_id, hire_date, gender) VALUES (101, 'Alice...
For each employee, list emp_id, first_name, last_name, current salary (the most recent salary_amount), and the salary rank within their department ordered by salary descending (rank 1 = highest). Order the result by dept_id ascending then rank ascending.
WITH latest_sal AS ( SELECT s.emp_id, s.salary_amount, ROW_NUMBER() OVER (PARTITION BY s.emp_id ORDER BY COALESCE(s.effective_to, '9999-12-31') DESC) AS rn FROM salaries s ) SELECT e.emp_id, e.first_name, e.last_name, ls.salary_amount, RANK() OVER (PARTITION BY e.dept_id ORDER BY ls.salary_amo...
SELECT e.emp_id, e.first_name, e.last_name, s.salary_amount, RANK() OVER (PARTITION BY e.dept_id ORDER BY s.salary_amount DESC) AS salary_rank FROM employees e JOIN salaries s ON e.emp_id = s.emp_id WHERE s.effective_to IS NULL ORDER BY e.dept_id ASC, salary_rank ASC;
15
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0008_4803a849_q4
prism_sql_0008_4803a849
Enterprise HR & Payroll
correlated_subqueries
CREATE TABLE departments ( dept_id INTEGER PRIMARY KEY, dept_name TEXT NOT NULL, location TEXT ); CREATE TABLE employees ( emp_id INTEGER PRIMARY KEY, first_name TEXT NOT NULL, last_name TEXT NOT NULL, dept_id INTEGER NOT NULL, hire_date TEXT NOT NULL, -- ISO date gender TEXT CHECK(...
INSERT INTO departments (dept_id, dept_name, location) VALUES (1, 'Engineering', 'New York'), (2, 'Human Resources', 'Chicago'), (3, 'Marketing', 'San Francisco'), (4, 'Finance', 'Boston'), (5, 'Legal', 'Washington'); INSERT INTO employees (emp_id, first_name, last_name, dept_id, hire_date, gender) VALUES (101, 'Alice...
For each department, return dept_name and the first_name and last_name of the employee whose current salary is the highest within that department. If multiple employees tie, return the one with the earliest hire_date. Order by dept_name alphabetically.
SELECT d.dept_name, (SELECT e.first_name FROM employees e JOIN salaries s ON e.emp_id = s.emp_id WHERE e.dept_id = d.dept_id AND s.effective_to IS NULL ORDER BY s.salary_amount DESC, e.hire_date ASC LIMIT 1) AS first_name, (SELECT e.last_name FROM employees e JOIN salaries ...
SELECT d.dept_name, e.first_name, e.last_name FROM departments d JOIN employees e ON d.dept_id = e.dept_id JOIN salaries s ON e.emp_id = s.emp_id WHERE s.effective_to IS NULL AND s.salary_amount = ( SELECT MAX(s2.salary_amount) FROM salaries s2 JOIN employees e2 ON s2.emp_id = e2.emp_id WHERE s2.effec...
5
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0009_642eba9f_q0
prism_sql_0009_642eba9f
Hotel & Hospitality Chain
window_functions
CREATE TABLE hotels ( hotel_id INTEGER PRIMARY KEY, hotel_name TEXT NOT NULL, city TEXT NOT NULL, opening_date TEXT NOT NULL -- stored as ISO date ); CREATE TABLE rooms ( room_id INTEGER PRIMARY KEY, hotel_id INTEGER NOT NULL, room_number TEXT NOT NULL, room_type TEXT NOT NULL CHECK(roo...
INSERT INTO hotels (hotel_id,hotel_name,city,opening_date) VALUES (1,'Grand Plaza','New York','2010-05-12'), (2,'Sea Breeze Resort','Miami','2015-07-01'), (3,'Mountain Lodge','Denver','2012-09-20'), (4,'Urban Stay','Chicago','2018-03-15'), (5,'Desert Oasis','Phoenix','2020-11-05'); INSERT INTO rooms (room_id,hotel_id,...
List each hotel with its total room revenue (sum of amount from room_charges for reservations with status 'CheckedIn') and the hotel's ranking based on that revenue in descending order. Return hotel_id, hotel_name, total_revenue rounded to 2 decimals, and rank (1 = highest revenue). Order by rank ascending.
WITH rev AS ( SELECT h.hotel_id, h.hotel_name, ROUND(COALESCE(SUM(rc.amount),0),2) AS total_revenue FROM hotels h LEFT JOIN rooms r ON r.hotel_id = h.hotel_id LEFT JOIN reservations res ON res.room_id = r.room_id AND res.status = 'CheckedIn' LEFT JOIN room_charges rc ON rc.reservation_id = res.reser...
WITH hotel_revenue AS ( SELECT h.hotel_id, h.hotel_name, ROUND(SUM(rc.amount), 2) AS total_revenue FROM hotels h JOIN rooms r ON h.hotel_id = r.hotel_id JOIN reservations res ON r.room_id = res.room_id JOIN room_charges rc ON res.reservation_id = rc.reservation_id WHERE ...
5
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0009_642eba9f_q1
prism_sql_0009_642eba9f
Hotel & Hospitality Chain
multiple_joins
CREATE TABLE hotels ( hotel_id INTEGER PRIMARY KEY, hotel_name TEXT NOT NULL, city TEXT NOT NULL, opening_date TEXT NOT NULL -- stored as ISO date ); CREATE TABLE rooms ( room_id INTEGER PRIMARY KEY, hotel_id INTEGER NOT NULL, room_number TEXT NOT NULL, room_type TEXT NOT NULL CHECK(roo...
INSERT INTO hotels (hotel_id,hotel_name,city,opening_date) VALUES (1,'Grand Plaza','New York','2010-05-12'), (2,'Sea Breeze Resort','Miami','2015-07-01'), (3,'Mountain Lodge','Denver','2012-09-20'), (4,'Urban Stay','Chicago','2018-03-15'), (5,'Desert Oasis','Phoenix','2020-11-05'); INSERT INTO rooms (room_id,hotel_id,...
Find all guests who stayed in a Suite room in Miami (city='Miami') during 2023, showing guest_id, full name (first_name||' '||last_name), hotel_name, check_in date, and check_out date. Order by check_in ascending.
SELECT g.guest_id, g.first_name || ' ' || g.last_name AS full_name, h.hotel_name, res.check_in, res.check_out FROM guests g JOIN reservations res ON res.guest_id = g.guest_id JOIN rooms r ON r.room_id = res.room_id JOIN hotels h ON h.hotel_id = r.hotel_id WHERE h.city = 'Miami' AND r.room_...
SELECT g.guest_id, g.first_name || ' ' || g.last_name AS full_name, h.hotel_name, r.check_in, r.check_out FROM guests g JOIN reservations r ON g.guest_id = r.guest_id JOIN rooms ro ON r.room_id = ro.room_id JOIN hotels h ON ro.hotel_id = h.hotel_id WHERE ro.room_type = 'Suite' AND h.city = 'Miami' AND r.check_in >= '20...
1
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0009_642eba9f_q4
prism_sql_0009_642eba9f
Hotel & Hospitality Chain
correlated_subqueries
CREATE TABLE hotels ( hotel_id INTEGER PRIMARY KEY, hotel_name TEXT NOT NULL, city TEXT NOT NULL, opening_date TEXT NOT NULL -- stored as ISO date ); CREATE TABLE rooms ( room_id INTEGER PRIMARY KEY, hotel_id INTEGER NOT NULL, room_number TEXT NOT NULL, room_type TEXT NOT NULL CHECK(roo...
INSERT INTO hotels (hotel_id,hotel_name,city,opening_date) VALUES (1,'Grand Plaza','New York','2010-05-12'), (2,'Sea Breeze Resort','Miami','2015-07-01'), (3,'Mountain Lodge','Denver','2012-09-20'), (4,'Urban Stay','Chicago','2018-03-15'), (5,'Desert Oasis','Phoenix','2020-11-05'); INSERT INTO rooms (room_id,hotel_id,...
For each reservation that is currently 'Booked', show reservation_id, guest full name, hotel_name, and the total amount already charged for that reservation (if none, show 0). Order by total_charged descending, then reservation_id ascending.
SELECT res.reservation_id, g.first_name || ' ' || g.last_name AS guest_name, h.hotel_name, COALESCE((SELECT SUM(rc.amount) FROM room_charges rc WHERE rc.reservation_id = res.reservation_id),0) AS total_charged FROM reservations res JOIN guests g ON g.guest_id = res.guest_id JOIN rooms r ON r.room_i...
SELECT r.reservation_id, g.first_name || ' ' || g.last_name AS guest_full_name, h.hotel_name, COALESCE(SUM(rc.amount), 0) AS total_charged FROM reservations r JOIN guests g ON r.guest_id = g.guest_id JOIN rooms rm ON r.room_id = rm.room_id JOIN hotels h ON rm.hotel_id = h.hotel_id LEFT JOIN room_charges rc ON r.reserva...
4
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0009_642eba9f_q5
prism_sql_0009_642eba9f
Hotel & Hospitality Chain
complex_aggregation
CREATE TABLE hotels ( hotel_id INTEGER PRIMARY KEY, hotel_name TEXT NOT NULL, city TEXT NOT NULL, opening_date TEXT NOT NULL -- stored as ISO date ); CREATE TABLE rooms ( room_id INTEGER PRIMARY KEY, hotel_id INTEGER NOT NULL, room_number TEXT NOT NULL, room_type TEXT NOT NULL CHECK(roo...
INSERT INTO hotels (hotel_id,hotel_name,city,opening_date) VALUES (1,'Grand Plaza','New York','2010-05-12'), (2,'Sea Breeze Resort','Miami','2015-07-01'), (3,'Mountain Lodge','Denver','2012-09-20'), (4,'Urban Stay','Chicago','2018-03-15'), (5,'Desert Oasis','Phoenix','2020-11-05'); INSERT INTO rooms (room_id,hotel_id,...
Identify the top 3 hotels by total revenue from room charges for reservations in 2023 (include only reservations with status 'CheckedIn'). For each, return hotel_id, hotel_name, total_revenue rounded to 2 decimals, and the percentage of that hotel's revenue relative to the combined revenue of the top 3 (rounded to 1 de...
WITH rev AS ( SELECT h.hotel_id, h.hotel_name, SUM(rc.amount) AS revenue FROM hotels h JOIN rooms r ON r.hotel_id = h.hotel_id JOIN reservations res ON res.room_id = r.room_id JOIN room_charges rc ON rc.reservation_id = res.reservation_id WHERE res.status = 'CheckedIn' AND substr(res.check...
WITH hotel_revenue AS ( SELECT h.hotel_id, h.hotel_name, ROUND(SUM(rc.amount), 2) AS total_revenue FROM hotels h JOIN rooms r ON h.hotel_id = r.hotel_id JOIN reservations res ON r.room_id = res.room_id JOIN room_charges rc ON res.reservation_id = rc.reservation_id WHERE ...
3
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0010_02c6cf30_q0
prism_sql_0010_02c6cf30
Commercial Real Estate Portfolio
window_functions
CREATE TABLE properties ( property_id INTEGER PRIMARY KEY, name TEXT NOT NULL, city TEXT NOT NULL, built_year INTEGER, active INTEGER NOT NULL CHECK (active IN (0,1)) ); CREATE TABLE units ( unit_id INTEGER PRIMARY KEY, property_id INTEGER NOT NULL, unit_number TEXT NOT NULL, square...
INSERT INTO properties (property_id, name, city, built_year, active) VALUES (1, 'Riverfront Plaza', 'Chicago', 1998, 1), (2, 'Sunnyvale Center', 'San Jose', 2005, 1), (3, 'Maple Tower', 'Boston', 2010, 0), (4, 'Cedar Heights', 'Seattle', 2015, 1), (5, 'Oakridge Complex', 'Denver', 2000, 1); INSERT INTO units (unit_id,...
List each active unit (unit_id, unit_number) together with the cumulative total rent (rounded to 2 decimals) of all leases that started on or before the unit's most recent lease start date, ordered by cumulative rent descending and then unit_id ascending.
WITH latest_lease AS ( SELECT u.unit_id, u.unit_number, MAX(l.start_date) AS last_start FROM units u JOIN leases l ON u.unit_id = l.unit_id WHERE u.active = 1 GROUP BY u.unit_id ) SELECT u.unit_id, u.unit_number, ROUND(SUM(l.monthly_rent) OVER (PARTITION BY u.unit_id ORDER BY l.start_d...
SELECT u.unit_id, u.unit_number, ROUND(SUM(l.monthly_rent), 2) AS cumulative_total_rent FROM units u JOIN leases l ON u.unit_id = l.unit_id WHERE u.active = 1 AND l.start_date <= ( SELECT MAX(l2.start_date) FROM leases l2 WHERE l2.unit_id = u.unit_id ) GROUP BY ...
9
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0010_02c6cf30_q5
prism_sql_0010_02c6cf30
Commercial Real Estate Portfolio
complex_aggregation
CREATE TABLE properties ( property_id INTEGER PRIMARY KEY, name TEXT NOT NULL, city TEXT NOT NULL, built_year INTEGER, active INTEGER NOT NULL CHECK (active IN (0,1)) ); CREATE TABLE units ( unit_id INTEGER PRIMARY KEY, property_id INTEGER NOT NULL, unit_number TEXT NOT NULL, square...
INSERT INTO properties (property_id, name, city, built_year, active) VALUES (1, 'Riverfront Plaza', 'Chicago', 1998, 1), (2, 'Sunnyvale Center', 'San Jose', 2005, 1), (3, 'Maple Tower', 'Boston', 2010, 0), (4, 'Cedar Heights', 'Seattle', 2015, 1), (5, 'Oakridge Complex', 'Denver', 2000, 1); INSERT INTO units (unit_id,...
Compute, for each month in 2023, the total cost of resolved maintenance tickets and the average cost of tickets (rounded to 2 decimals) that were reported that month, regardless of resolution status. Show month as YYYY-MM, total_resolved_cost, avg_reported_cost, ordered chronologically.
SELECT strftime('%Y-%m', reported_date) AS month, ROUND(SUM(CASE WHEN resolved_date IS NOT NULL THEN cost ELSE 0 END), 2) AS total_resolved_cost, ROUND(AVG(cost), 2) AS avg_reported_cost FROM maintenance_tickets WHERE strftime('%Y', reported_date) = '2023' GROUP BY month ORDER BY month ASC;
SELECT strftime('%Y-%m', reported_date) AS month, SUM(CASE WHEN resolved_date IS NOT NULL THEN cost ELSE 0 END) AS total_resolved_cost, ROUND(AVG(cost), 2) AS avg_reported_cost FROM maintenance_tickets WHERE strftime('%Y', reported_date) = '2023' GROUP BY month ORDER BY month;
7
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0012_ad395806_q1
prism_sql_0012_ad395806
Retail Pharmacy Inventory
multiple_joins
CREATE TABLE stores ( store_id INTEGER PRIMARY KEY, store_name TEXT NOT NULL, city TEXT NOT NULL ); CREATE TABLE drugs ( drug_id INTEGER PRIMARY KEY, drug_name TEXT NOT NULL, category TEXT NOT NULL ); CREATE TABLE batches ( batch_id INTEGER PRIMARY KEY, drug_id INTEGER NOT NULL, lo...
INSERT INTO stores (store_id, store_name, city) VALUES (1, 'HealthPlus Downtown', 'Metropolis'), (2, 'HealthPlus Uptown', 'Metropolis'), (3, 'MediCare West', 'Gotham'), (4, 'MediCare East', 'Gotham'), (5, 'PharmaDirect', 'Star City'); INSERT INTO drugs (drug_id, drug_name, category) VALUES (1, 'Aspirin', 'Analgesic'),...
Retrieve the store_name, city, drug_name, and total quantity dispensed (sum of quantity) for every combination where the store has dispensed that drug at least once via the 'online' channel. Order by total quantity descending, then store_name ascending.
SELECT s.store_name, s.city, dr.drug_name, SUM(dp.quantity) AS total_qty FROM dispensations dp JOIN batches b ON dp.batch_id = b.batch_id JOIN stores s ON b.store_id = s.store_id JOIN drugs dr ON b.drug_id = dr.drug_id WHERE dp.channel = 'online' GROUP BY s.store_id, dr.drug_id HAVING SUM(dp.quanti...
SELECT s.store_name, s.city, d.drug_name, SUM(dis.quantity) AS total_quantity FROM stores s JOIN batches b ON s.store_id = b.store_id JOIN drugs d ON b.drug_id = d.drug_id JOIN dispensations dis ON b.batch_id = dis.batch_id WHERE dis.channel = 'online' GROUP BY s.store_name, s.city, d.drug_name HAVING COUNT(dis.disp_id...
10
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0012_ad395806_q2
prism_sql_0012_ad395806
Retail Pharmacy Inventory
cte_multi_step
CREATE TABLE stores ( store_id INTEGER PRIMARY KEY, store_name TEXT NOT NULL, city TEXT NOT NULL ); CREATE TABLE drugs ( drug_id INTEGER PRIMARY KEY, drug_name TEXT NOT NULL, category TEXT NOT NULL ); CREATE TABLE batches ( batch_id INTEGER PRIMARY KEY, drug_id INTEGER NOT NULL, lo...
INSERT INTO stores (store_id, store_name, city) VALUES (1, 'HealthPlus Downtown', 'Metropolis'), (2, 'HealthPlus Uptown', 'Metropolis'), (3, 'MediCare West', 'Gotham'), (4, 'MediCare East', 'Gotham'), (5, 'PharmaDirect', 'Star City'); INSERT INTO drugs (drug_id, drug_name, category) VALUES (1, 'Aspirin', 'Analgesic'),...
First, compute the total quantity dispensed per batch. Then, list batch_id, lot_number, and the percentage of the batch's total that was dispensed (rounded to two decimals). Exclude batches with zero dispensed quantity. Order by percentage descending.
WITH batch_totals AS ( SELECT b.batch_id, b.lot_number, SUM(dp.quantity) AS disp_qty FROM batches b LEFT JOIN dispensations dp ON b.batch_id = dp.batch_id GROUP BY b.batch_id ) SELECT batch_id, lot_number, ROUND(CASE WHEN disp_qty IS NULL THEN 0 ELSE (disp_qty * 100.0...
WITH batch_totals AS ( SELECT b.batch_id, b.lot_number, SUM(d.quantity) AS total_dispensed FROM batches b JOIN dispensations d ON b.batch_id = d.batch_id GROUP BY b.batch_id, b.lot_number HAVING SUM(d.quantity) > 0 ), batch_max AS ( SELECT batch_id, MAX(to...
15
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0012_ad395806_q4
prism_sql_0012_ad395806
Retail Pharmacy Inventory
correlated_subqueries
CREATE TABLE stores ( store_id INTEGER PRIMARY KEY, store_name TEXT NOT NULL, city TEXT NOT NULL ); CREATE TABLE drugs ( drug_id INTEGER PRIMARY KEY, drug_name TEXT NOT NULL, category TEXT NOT NULL ); CREATE TABLE batches ( batch_id INTEGER PRIMARY KEY, drug_id INTEGER NOT NULL, lo...
INSERT INTO stores (store_id, store_name, city) VALUES (1, 'HealthPlus Downtown', 'Metropolis'), (2, 'HealthPlus Uptown', 'Metropolis'), (3, 'MediCare West', 'Gotham'), (4, 'MediCare East', 'Gotham'), (5, 'PharmaDirect', 'Star City'); INSERT INTO drugs (drug_id, drug_name, category) VALUES (1, 'Aspirin', 'Analgesic'),...
List each store_name and the most recent dispense_date (latest) of any dispensation that occurred in that store. If a store has no dispensations, show NULL for the date. Order by store_name ascending.
SELECT s.store_name, (SELECT MAX(dp.dispense_date) FROM dispensations dp JOIN batches b ON dp.batch_id = b.batch_id WHERE b.store_id = s.store_id) AS latest_dispense FROM stores s ORDER BY s.store_name ASC;
SELECT s.store_name, MAX(d.dispense_date) AS dispense_date FROM stores s LEFT JOIN batches b ON s.store_id = b.store_id LEFT JOIN dispensations d ON b.batch_id = d.batch_id GROUP BY s.store_id, s.store_name ORDER BY s.store_name ASC;
5
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0012_ad395806_q5
prism_sql_0012_ad395806
Retail Pharmacy Inventory
complex_aggregation
CREATE TABLE stores ( store_id INTEGER PRIMARY KEY, store_name TEXT NOT NULL, city TEXT NOT NULL ); CREATE TABLE drugs ( drug_id INTEGER PRIMARY KEY, drug_name TEXT NOT NULL, category TEXT NOT NULL ); CREATE TABLE batches ( batch_id INTEGER PRIMARY KEY, drug_id INTEGER NOT NULL, lo...
INSERT INTO stores (store_id, store_name, city) VALUES (1, 'HealthPlus Downtown', 'Metropolis'), (2, 'HealthPlus Uptown', 'Metropolis'), (3, 'MediCare West', 'Gotham'), (4, 'MediCare East', 'Gotham'), (5, 'PharmaDirect', 'Star City'); INSERT INTO drugs (drug_id, drug_name, category) VALUES (1, 'Aspirin', 'Analgesic'),...
For each drug category, compute the average quantity per dispensation (rounded to two decimals) and the total number of distinct stores that have dispensed drugs from that category. Return category, avg_qty, store_count ordered by avg_qty descending.
SELECT dr.category, ROUND(AVG(dp.quantity), 2) AS avg_qty, COUNT(DISTINCT b.store_id) AS store_count FROM dispensations dp JOIN batches b ON dp.batch_id = b.batch_id JOIN drugs dr ON b.drug_id = dr.drug_id GROUP BY dr.category ORDER BY avg_qty DESC;
SELECT d.category, ROUND(AVG(dis.quantity), 2) AS avg_qty, COUNT(DISTINCT b.store_id) AS store_count FROM drugs d JOIN batches b ON d.drug_id = b.drug_id JOIN dispensations dis ON b.batch_id = dis.batch_id GROUP BY d.category ORDER BY avg_qty DESC;
5
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
prism_sql_0014_64779909_q0
prism_sql_0014_64779909
E-Learning Certification Platform
window_functions
CREATE TABLE learners ( learner_id INTEGER PRIMARY KEY, first_name TEXT NOT NULL, last_name TEXT NOT NULL, signup_date TEXT NOT NULL -- stored as ISO YYYY-MM-DD ); CREATE TABLE tracks ( track_id INTEGER PRIMARY KEY, track_name TEXT NOT NULL, category TEXT NOT NULL ); CREATE TABLE modules (...
INSERT INTO learners (learner_id, first_name, last_name, signup_date) VALUES (1, 'Alice', 'Smith', '2022-01-15'), (2, 'Bob', 'Jones', '2022-02-20'), (3, 'Carol', 'Taylor', '2022-03-05'), (4, 'David', 'Brown', '2022-04-10'), (5, 'Eva', 'Davis', '2022-05-22'), (6, 'Frank', 'Miller', '2022-06-30'), (7, 'Grace', 'Wilson', ...
For each learner who has at least one exam attempt, return learner_id, first_name, last_name, the total number of attempts, and the rank (1 = most attempts) of the learner by total attempts descending. Order the result by rank ascending.
SELECT l.learner_id, l.first_name, l.last_name, cnt.total_attempts, RANK() OVER (ORDER BY cnt.total_attempts DESC) AS rank_by_attempts FROM ( SELECT learner_id, COUNT(*) AS total_attempts FROM exam_attempts GROUP BY learner_id ) cnt JOIN learners l ON l.learner_id = cnt.learner_id ORDER BY rank_by_at...
SELECT l.learner_id, l.first_name, l.last_name, COUNT(ea.attempt_id) AS total_attempts, RANK() OVER (ORDER BY COUNT(ea.attempt_id) DESC) AS rank FROM learners l JOIN exam_attempts ea ON l.learner_id = ea.learner_id GROUP BY l.learner_id, l.first_name, l.last_name ORDER BY rank ASC;
20
true
openai/gpt-oss-120b
qwen/qwen3.6-35b-a3b
apache-2.0
End of preview. Expand in Data Studio

YAML Metadata Warning:The task_categories "text-to-sql" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other

Flintglass PrismSQL-Hard-Corpus

5,916 Dual-Model Live-SQLite Execution-Verified Hard Analytical Text-to-SQL Tasks Across 1,773 Unique Populated Multi-Table Enterprise Schemas (50 Domains) β€” 100% Apache-2.0!

Most open-source Text-to-SQL datasets skew heavily toward simple single-table SELECT and basic GROUP BY queries, causing open-weight SQL models to plateau at 40–55% on Window Functions, Multi-Table Joins, Multi-Step CTEs, Set Operations, and Correlated Subqueries.

flintglass/PrismSQL-Hard-Corpus targets those exact failure modes with near-zero label noise via a 3-Stage Live-SQLite Dual-Model Verification Gate using strictly Apache-2.0 open-weight models only (zero proprietary API distillation, zero benchmark contamination):

  1. Schema & Data Synthesis (openai/gpt-oss-120b, Apache-2.0): Generates realistic 4–5 table normalized SQLite DDL schemas, 35–55 populated INSERT rows (with ties, NULLs, dates, and unmatched rows for LEFT JOIN / EXCEPT / NOT EXISTS), and hard analytical questions.
  2. Live SQLite Execution & AST Complexity Gate (sqlite3): Executes every schema + seed data + gold query live in SQLite and enforces exact SQL construct presence (OVER (, WITH , >= 2 JOIN, UNION/INTERSECT/EXCEPT, nested SELECT).
  3. Independent Cross-Model Execution Verification (qwen/qwen3.6-35b-a3b, Apache-2.0): A completely independent Apache-2.0 model sees ONLY (schema_ddl, question) and writes its own SQLite query. Only tasks where BOTH independent models execute cleanly on the populated SQLite DB and return 100% identical canonicalized result sets are kept (dual_verified=True)!

Part of the Flintglass Prism Open-Source Agent & RAG Stack Β· Pairs Directly With: flintglass/PrismSQL-8B, flintglass/PrismSQL-27B, flintglass/PrismSQL-35B-A3B, flintglass/GPT-OSS-20B-PrismSQL


Dataset Statistics (Schema-Disjoint Zero-Leakage Splits)

Split Verified Examples Unique Schemas Purpose
train 4,843 1,454 Execution-verified RLVR / SFT training
validation 356 106 Hyperparameter & checkpoint selection
hard_test 717 213 Zero-leakage Hard Analytical SQLite Execution Benchmark
Total 5,916 1,773 50 Real-World Enterprise Domains

Complexity Category Breakdown

Hard SQL Category Verified Examples Share Constructs Enforced
multiple_joins 1,349 22.8% 3–5 table INNER/LEFT joins + GROUP BY/HAVING
correlated_subqueries 1,074 18.2% EXISTS, NOT EXISTS, nested & correlated SELECT
cte_multi_step 1,013 17.1% Multi-step WITH ... AS (...) analytical pipelines
window_functions 981 16.6% ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, running SUM() OVER (...)
complex_aggregation 930 15.7% Conditional SUM(CASE WHEN ...) + GROUP BY + HAVING
set_operations 569 9.6% UNION, UNION ALL, INTERSECT, EXCEPT

Quickstart (datasets + Live sqlite3 Execution)

import sqlite3
from datasets import load_dataset

ds = load_dataset("flintglass/PrismSQL-Hard-Corpus", split="hard_test")
row = ds[0]

conn = sqlite3.connect(":memory:")
conn.executescript(row["schema_ddl"])
conn.executescript(row["seed_inserts"])

gold_rows = conn.execute(row["sql"]).fetchall()
alt_rows = conn.execute(row["alt_verified_sql"]).fetchall()
print("Domain:", row["domain"], "| Category:", row["category"])
print("Question:", row["question"])
print("Result rows:", len(gold_rows), "| Dual-model exact match:", sorted(gold_rows) == sorted(alt_rows))

Schema Fields

  • id (string): Unique example identifier
  • schema_id (string): Schema group ID (strictly disjoint across train, validation, and hard_test)
  • domain (string): One of 50 enterprise database domains (FinTech, EHR, Cloud Telemetry, Supply Chain, Clinical Trials, Semiconductor Fab, Maritime Shipping, etc.)
  • category (string): Hard SQL complexity class
  • schema_ddl (string): Executable SQLite CREATE TABLE DDL statements
  • seed_inserts (string): Executable SQLite INSERT INTO statements populating 35–55 realistic test rows
  • question (string): Unambiguous analytical natural-language query
  • sql (string): Primary live-SQLite verified gold query (openai/gpt-oss-120b)
  • alt_verified_sql (string): Independent cross-verified SQLite query (qwen/qwen3.6-35b-a3b) producing the exact same result set
  • num_result_rows (int): Number of live result rows returned
  • dual_verified (bool): Always true
  • license (string): apache-2.0

πŸ† 12-Model Open-Weight Reference Leaderboard (hard_test)

Evaluated deterministically (zero LLM-as-a-judge) on the exact hard_test split. Explore interactive breakdowns & all 5 OOD suites live on flintglass/PrismBench-Leaderboard.

† denotes models from the Apache-2.0 dual-model generation/verification family.

Rank Model License Live SQLite Exec Acc Valid SQL Rate
1 GPT-OSS-120B † Apache-2.0 92.61% 98.47%
2 Qwen3.8-27B (Base) Apache-2.0 91.91% 98.33%
3 Gemma-4-31B-IT Apache-2.0 91.49% 98.33%
4 Qwen3.6-35B-A3B † Apache-2.0 90.38% 98.05%
5 DeepSeek-V3.2 MIT 89.68% 98.33%
6 Gemma-4-26B-A4B-IT Apache-2.0 89.40% 98.33%
7 GPT-OSS-20B (Base) Apache-2.0 89.12% 96.23%
8 Qwen3-Coder-30B-A3B Apache-2.0 88.98% 98.19%
9 Llama-3.3-70B-Instruct Llama-3.3 83.12% 95.12%
10 Mistral-Small-2603 (24B) Apache-2.0 81.59% 95.40%
11 Qwen3.5-9B (Base) Apache-2.0 74.62% 92.33%
12 DeepSeek-V4.1-Flash MIT 60.67% 93.17%
Downloads last month
56

Space using flintglass/PrismSQL-Hard-Corpus 1

Collection including flintglass/PrismSQL-Hard-Corpus