Dataset Viewer
Auto-converted to Parquet
question_id
int64
5
1.53k
db_id
stringclasses
11 values
question
stringlengths
23
286
evidence
stringlengths
0
468
SQL
stringlengths
35
1.58k
difficulty
stringclasses
3 values
1,471
debit_card_specializing
What is the ratio of customers who pay in EUR against customers who pay in CZK?
ratio of customers who pay in EUR against customers who pay in CZK = count(Currency = 'EUR') / count(Currency = 'CZK').
SELECT CAST(SUM(CASE WHEN `Currency` = 'EUR' THEN 1 ELSE 0 END) AS DOUBLE) / SUM(CASE WHEN `Currency` = 'CZK' THEN 1 ELSE 0 END) FROM `customers`
simple
1,472
debit_card_specializing
In 2012, who had the least consumption in LAM?
Year 2012 can be presented as Between 201201 And 201212; The first 4 strings of the Date values in the yearmonth table can represent year.
SELECT `T1`.`CustomerID` FROM `customers` AS `T1` INNER JOIN `yearmonth` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE `T1`.`Segment` = 'LAM' AND SUBSTR(`T2`.`Date`, 1, 4) = '2012' GROUP BY `T1`.`CustomerID` ORDER BY SUM(`T2`.`Consumption`) ASC LIMIT 1
moderate
1,473
debit_card_specializing
What was the average monthly consumption of customers in SME for the year 2013?
Average Monthly consumption = AVG(Consumption) / 12; Year 2013 can be presented as Between 201301 And 201312; The first 4 strings of the Date values in the yearmonth table can represent year.
SELECT AVG(`T2`.`Consumption`) / 12 FROM `customers` AS `T1` INNER JOIN `yearmonth` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE SUBSTR(`T2`.`Date`, 1, 4) = '2013' AND `T1`.`Segment` = 'SME'
moderate
1,476
debit_card_specializing
What was the difference in gas consumption between CZK-paying customers and EUR-paying customers in 2012?
Year 2012 can be presented as Between 201201 And 201212; The first 4 strings of the Date values in the yearmonth table can represent year; Difference in Consumption = CZK customers consumption in 2012 - EUR customers consumption in 2012
SELECT SUM(CASE WHEN `T1`.`Currency` = 'CZK' THEN `T2`.`Consumption` ELSE 0 END) - SUM(CASE WHEN `T1`.`Currency` = 'EUR' THEN `T2`.`Consumption` ELSE 0 END) FROM `customers` AS `T1` INNER JOIN `yearmonth` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE SUBSTR(`T2`.`Date`, 1, 4) = '2012'
challenging
1,479
debit_card_specializing
Which year recorded the most consumption of gas paid in CZK?
The first 4 strings of the Date values in the yearmonth table can represent year.
SELECT SUBSTR(`T2`.`Date`, 1, 4) FROM `customers` AS `T1` INNER JOIN `yearmonth` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE `T1`.`Currency` = 'CZK' GROUP BY SUBSTR(`T2`.`Date`, 1, 4) ORDER BY SUM(`T2`.`Consumption`) DESC LIMIT 1
moderate
1,480
debit_card_specializing
What was the gas consumption peak month for SME customers in 2013?
Year 2013 can be presented as Between 201301 And 201312; The first 4 strings of the Date values in the yearmonth table can represent year; The 5th and 6th string of the date can refer to month.
SELECT SUBSTR(`T2`.`Date`, 5, 2) FROM `customers` AS `T1` INNER JOIN `yearmonth` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE SUBSTR(`T2`.`Date`, 1, 4) = '2013' AND `T1`.`Segment` = 'SME' GROUP BY SUBSTR(`T2`.`Date`, 5, 2) ORDER BY SUM(`T2`.`Consumption`) DESC LIMIT 1
moderate
1,481
debit_card_specializing
What is the difference in the annual average consumption of the customers with the least amount of consumption paid in CZK for 2013 between SME and LAM, LAM and KAM, and KAM and SME?
annual average consumption of customer with the lowest consumption in each segment = total consumption per year / the number of customer with lowest consumption in each segment; Difference in annual average = SME's annual average - LAM's annual average; Difference in annual average = LAM's annual average - KAM's annual average; Year 2013 can be presented as Between 201301 And 201312; The first 4 strings of the Date values in the yearmonth table can represent year.
SELECT CAST(SUM(CASE WHEN `T1`.`Segment` = 'SME' THEN `T2`.`Consumption` ELSE 0 END) AS DOUBLE) / COUNT(`T1`.`CustomerID`) - CAST(SUM(CASE WHEN `T1`.`Segment` = 'LAM' THEN `T2`.`Consumption` ELSE 0 END) AS DOUBLE) / COUNT(`T1`.`CustomerID`), CAST(SUM(CASE WHEN `T1`.`Segment` = 'LAM' THEN `T2`.`Consumption` ELSE 0 END) AS DOUBLE) / COUNT(`T1`.`CustomerID`) - CAST(SUM(CASE WHEN `T1`.`Segment` = 'KAM' THEN `T2`.`Consumption` ELSE 0 END) AS DOUBLE) / COUNT(`T1`.`CustomerID`), CAST(SUM(CASE WHEN `T1`.`Segment` = 'KAM' THEN `T2`.`Consumption` ELSE 0 END) AS DOUBLE) / COUNT(`T1`.`CustomerID`) - CAST(SUM(CASE WHEN `T1`.`Segment` = 'SME' THEN `T2`.`Consumption` ELSE 0 END) AS DOUBLE) / COUNT(`T1`.`CustomerID`) FROM `customers` AS `T1` INNER JOIN `yearmonth` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE `T1`.`Currency` = 'CZK' AND `T2`.`Consumption` = ( SELECT MIN(`Consumption`) FROM `yearmonth` ) AND `T2`.`Date` BETWEEN 201301 AND 201312
challenging
1,482
debit_card_specializing
Which of the three segments—SME, LAM and KAM—has the biggest and lowest percentage increases in consumption paid in EUR between 2012 and 2013?
Increase or Decrease = consumption for 2013 - consumption for 2012; Percentage of Increase = (Increase or Decrease / consumption for 2013) * 100%; The first 4 strings of the Date values in the yearmonth table can represent year
SELECT CAST(( SUM( CASE WHEN `T1`.`Segment` = 'SME' AND `T2`.`Date` LIKE '2013%' THEN `T2`.`Consumption` ELSE 0 END ) - SUM( CASE WHEN `T1`.`Segment` = 'SME' AND `T2`.`Date` LIKE '2012%' THEN `T2`.`Consumption` ELSE 0 END ) ) AS DOUBLE) * 100 / SUM( CASE WHEN `T1`.`Segment` = 'SME' AND `T2`.`Date` LIKE '2012%' THEN `T2`.`Consumption` ELSE 0 END ), CAST(SUM( CASE WHEN `T1`.`Segment` = 'LAM' AND `T2`.`Date` LIKE '2013%' THEN `T2`.`Consumption` ELSE 0 END ) - SUM( CASE WHEN `T1`.`Segment` = 'LAM' AND `T2`.`Date` LIKE '2012%' THEN `T2`.`Consumption` ELSE 0 END ) AS DOUBLE) * 100 / SUM( CASE WHEN `T1`.`Segment` = 'LAM' AND `T2`.`Date` LIKE '2012%' THEN `T2`.`Consumption` ELSE 0 END ), CAST(SUM( CASE WHEN `T1`.`Segment` = 'KAM' AND `T2`.`Date` LIKE '2013%' THEN `T2`.`Consumption` ELSE 0 END ) - SUM( CASE WHEN `T1`.`Segment` = 'KAM' AND `T2`.`Date` LIKE '2012%' THEN `T2`.`Consumption` ELSE 0 END ) AS DOUBLE) * 100 / SUM( CASE WHEN `T1`.`Segment` = 'KAM' AND `T2`.`Date` LIKE '2012%' THEN `T2`.`Consumption` ELSE 0 END ) FROM `customers` AS `T1` INNER JOIN `yearmonth` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID`
challenging
1,483
debit_card_specializing
How much did customer 6 consume in total between August and November 2013?
Between August And November 2013 refers to Between 201308 And 201311; The first 4 strings of the Date values in the yearmonth table can represent year; The 5th and 6th string of the date can refer to month.
SELECT SUM(`Consumption`) FROM `yearmonth` WHERE `CustomerID` = 6 AND `Date` BETWEEN '201308' AND '201311'
simple
1,484
debit_card_specializing
How many more "discount" gas stations does the Czech Republic have compared to Slovakia?
Czech Republic can be represented as the Country value in gasstations table is 'CZE'; Slovakia can be represented as the Country value in the gasstations table is 'SVK'; Computation of more "discount" gas stations= Total no. of discount gas stations in Czech Republic - Total no. of discount gas stations in Slovakia
SELECT SUM(CASE WHEN `Country` = 'CZE' THEN 1 ELSE 0 END) - SUM(CASE WHEN `Country` = 'SVK' THEN 1 ELSE 0 END) FROM `gasstations` WHERE `Segment` = 'Discount'
simple
1,486
debit_card_specializing
Is it true that more SMEs pay in Czech koruna than in euros? If so, how many more?
Amount of more SMEs = Total of SMEs pay using Currency CZK - Total of SMEs pay using Currency EUR
SELECT SUM(`Currency` = 'CZK') - SUM(`Currency` = 'EUR') FROM `customers` WHERE `Segment` = 'SME'
simple
1,490
debit_card_specializing
How many percent of LAM customer consumed more than 46.73?
Percentage of LAM customer consumed more than 46.73 = (Total no. of LAM customers who consumed more than 46.73 / Total no. of LAM customers) * 100.
SELECT CAST(SUM(CASE WHEN `T2`.`Consumption` > 46.73 THEN 1 ELSE 0 END) AS DOUBLE) * 100 / COUNT(`T1`.`CustomerID`) FROM `customers` AS `T1` INNER JOIN `yearmonth` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE `T1`.`Segment` = 'LAM'
moderate
1,493
debit_card_specializing
In February 2012, what percentage of customers consumed more than 528.3?
February 2012 refers to '201202' in yearmonth.date; The first 4 strings of the Date values in the yearmonth table can represent year; The 5th and 6th string of the date can refer to month.
SELECT CAST(SUM(CASE WHEN `Consumption` > 528.3 THEN 1 ELSE 0 END) AS DOUBLE) * 100 / COUNT(`CustomerID`) FROM `yearmonth` WHERE `Date` = '201202'
simple
1,498
debit_card_specializing
What is the highest monthly consumption in the year 2012?
The first 4 strings of the Date values in the yearmonth table can represent year; The 5th and 6th string of the date can refer to month.
SELECT SUM(`Consumption`) FROM `yearmonth` WHERE SUBSTR(`Date`, 1, 4) = '2012' GROUP BY SUBSTR(`Date`, 5, 2) ORDER BY SUM(`Consumption`) DESC LIMIT 1
simple
1,500
debit_card_specializing
Please list the product description of the products consumed in September, 2013.
September 2013 refers to 201309; The first 4 strings of the Date values in the yearmonth table can represent year; The 5th and 6th string of the date can refer to month.
SELECT `T3`.`Description` FROM `transactions_1k` AS `T1` INNER JOIN `yearmonth` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` INNER JOIN `products` AS `T3` ON `T1`.`ProductID` = `T3`.`ProductID` WHERE `T2`.`Date` = '201309'
simple
1,501
debit_card_specializing
Please list the countries of the gas stations with transactions taken place in June, 2013.
June 2013 refers to '201306'; The first 4 strings of the Date values in the yearmonth table can represent year; The 5th and 6th string of the date can refer to month;
SELECT DISTINCT `T2`.`Country` FROM `transactions_1k` AS `T1` INNER JOIN `gasstations` AS `T2` ON `T1`.`GasStationID` = `T2`.`GasStationID` INNER JOIN `yearmonth` AS `T3` ON `T1`.`CustomerID` = `T3`.`CustomerID` WHERE `T3`.`Date` = '201306'
moderate
1,505
debit_card_specializing
Among the customers who paid in euro, how many of them have a monthly consumption of over 1000?
Pays in euro = Currency = 'EUR'.
SELECT COUNT(*) FROM `yearmonth` AS `T1` INNER JOIN `customers` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE `T2`.`Currency` = 'EUR' AND `T1`.`Consumption` > 1000.00
simple
1,506
debit_card_specializing
Please list the product descriptions of the transactions taken place in the gas stations in the Czech Republic.
Czech Republic can be represented as the Country value in the gasstations table is 'CZE';
SELECT DISTINCT `T3`.`Description` FROM `transactions_1k` AS `T1` INNER JOIN `gasstations` AS `T2` ON `T1`.`GasStationID` = `T2`.`GasStationID` INNER JOIN `products` AS `T3` ON `T1`.`ProductID` = `T3`.`ProductID` WHERE `T2`.`Country` = 'CZE'
moderate
1,507
debit_card_specializing
Please list the disparate time of the transactions taken place in the gas stations from chain no. 11.
SELECT DISTINCT `T1`.`Time` FROM `transactions_1k` AS `T1` INNER JOIN `gasstations` AS `T2` ON `T1`.`GasStationID` = `T2`.`GasStationID` WHERE `T2`.`ChainID` = 11
simple
1,509
debit_card_specializing
Among the transactions made in the gas stations in the Czech Republic, how many of them are taken place after 2012/1/1?
Czech Republic can be represented as the Country value in the gasstations table is 'CZE'
SELECT COUNT(`T1`.`TransactionID`) FROM `transactions_1k` AS `T1` INNER JOIN `gasstations` AS `T2` ON `T1`.`GasStationID` = `T2`.`GasStationID` WHERE `T2`.`Country` = 'CZE' AND DATE_FORMAT(CAST(`T1`.`Date` AS DATETIME), '%Y') >= '2012'
moderate
1,514
debit_card_specializing
What kind of currency did the customer paid at 16:25:00 in 2012/8/24?
'2012/8/24' can be represented by '2012-08-24';
SELECT DISTINCT `T3`.`Currency` FROM `transactions_1k` AS `T1` INNER JOIN `gasstations` AS `T2` ON `T1`.`GasStationID` = `T2`.`GasStationID` INNER JOIN `customers` AS `T3` ON `T1`.`CustomerID` = `T3`.`CustomerID` WHERE `T1`.`Date` = '2012-08-24' AND `T1`.`Time` = '16:25:00'
simple
1,515
debit_card_specializing
What segment did the customer have at 2012/8/23 21:20:00?
'2012/8/23' can be represented by '2012-08-23'
SELECT `T2`.`Segment` FROM `transactions_1k` AS `T1` INNER JOIN `customers` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE `T1`.`date` = '2012-08-23' AND `T1`.`time` = '21:20:00'
simple
1,521
debit_card_specializing
For all the transactions happened during 8:00-9:00 in 2012/8/26, how many happened in CZE?
Czech Republic can be represented as the Country value in the gasstations table is 'CZE'; '2012/8/26' can be represented by '2012-08-26'; during 8:00-9:00 can be represented as Time BETWEEN '08:00:00' AND '09:00:00'
SELECT COUNT(`T1`.`TransactionID`) FROM `transactions_1k` AS `T1` INNER JOIN `gasstations` AS `T2` ON `T1`.`GasStationID` = `T2`.`GasStationID` WHERE `T1`.`Date` = '2012-08-26' AND `T1`.`Time` BETWEEN '08:00:00' AND '09:00:00' AND `T2`.`Country` = 'CZE'
moderate
1,524
debit_card_specializing
What's the nationality of the customer who spent 548.4 in 2012/8/24?
'2012/8/24' can be represented by '2012-08-24'
SELECT `T2`.`Country` FROM `transactions_1k` AS `T1` INNER JOIN `gasstations` AS `T2` ON `T1`.`GasStationID` = `T2`.`GasStationID` WHERE `T1`.`Date` = '2012-08-24' AND `T1`.`Price` = 548.4
simple
1,525
debit_card_specializing
What is the percentage of the customers who used EUR in 2012/8/25?
'2012/8/25' can be represented by '2012-08-25'
SELECT CAST(SUM(CASE WHEN `T2`.`Currency` = 'EUR' THEN 1 ELSE 0 END) AS DOUBLE) * 100 / COUNT(`T1`.`CustomerID`) FROM `transactions_1k` AS `T1` INNER JOIN `customers` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE `T1`.`Date` = '2012-08-25'
simple
1,526
debit_card_specializing
For the customer who paid 634.8 in 2012/8/25, what was the consumption decrease rate from Year 2012 to 2013?
'2012/8/24' can be represented by '2012-08-24'; Consumption decrease rate = (consumption_2012 - consumption_2013) / consumption_2012
SELECT CAST(SUM(CASE WHEN SUBSTR(`Date`, 1, 4) = '2012' THEN `Consumption` ELSE 0 END) - SUM(CASE WHEN SUBSTR(`Date`, 1, 4) = '2013' THEN `Consumption` ELSE 0 END) AS DOUBLE) / SUM(CASE WHEN SUBSTR(`Date`, 1, 4) = '2012' THEN `Consumption` ELSE 0 END) FROM `yearmonth` WHERE `CustomerID` = ( SELECT `T1`.`CustomerID` FROM `transactions_1k` AS `T1` INNER JOIN `gasstations` AS `T2` ON `T1`.`GasStationID` = `T2`.`GasStationID` WHERE `T1`.`Date` = '2012-08-25' AND `T1`.`Price` = 1513.12 )
challenging
1,528
debit_card_specializing
What is the percentage of "premium" against the overall segment in Country = "SVK"?
SELECT CAST(SUM(CASE WHEN `Country` = 'SVK' AND `Segment` = 'Premium' THEN 1 ELSE 0 END) AS DOUBLE) * 100 / SUM(CASE WHEN `Country` = 'SVK' THEN 1 ELSE 0 END) FROM `gasstations`
simple
1,529
debit_card_specializing
What is the amount spent by customer "38508" at the gas stations? How much had the customer spent in January 2012?
January 2012 refers to the Date value = '201201'
SELECT SUM(`T1`.`Price` ), SUM(CASE WHEN `T3`.`Date` = '201201' THEN `T1`.`Price` ELSE 0 END) FROM `transactions_1k` AS `T1` INNER JOIN `gasstations` AS `T2` ON `T1`.`GasStationID` = `T2`.`GasStationID` INNER JOIN `yearmonth` AS `T3` ON `T1`.`CustomerID` = `T3`.`CustomerID` WHERE `T1`.`CustomerID` = '38508'
moderate
1,531
debit_card_specializing
Who is the top spending customer and how much is the average price per single item purchased by this customer? What currency was being used?
average price per single item = Total(price) / Total(amount)
SELECT `T2`.`CustomerID`, SUM(`T2`.`Price` / `T2`.`Amount`), `T1`.`Currency` FROM `customers` AS `T1` INNER JOIN `transactions_1k` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE `T2`.`CustomerID` = ( SELECT `CustomerID` FROM `yearmonth` ORDER BY `Consumption` DESC LIMIT 1 ) GROUP BY `T2`.`CustomerID`, `T1`.`Currency`
moderate
1,533
debit_card_specializing
For all the people who paid more than 29.00 per unit of product id No.5. Give their consumption status in the August of 2012.
August of 2012 refers to the Date value = '201208' ; Price per unit of product = Price / Amount;
SELECT `T2`.`Consumption` FROM `transactions_1k` AS `T1` INNER JOIN `yearmonth` AS `T2` ON `T1`.`CustomerID` = `T2`.`CustomerID` WHERE `T1`.`Price` / `T1`.`Amount` > 29.00 AND `T1`.`ProductID` = 5 AND `T2`.`Date` = '201208'
moderate
1,312
student_club
What's Angela Sanders's major?
Angela Sanders is the full name; full name refers to first_name, last_name; major refers to major_name.
SELECT `T2`.`major_name` FROM `member` AS `T1` INNER JOIN `major` AS `T2` ON `T1`.`link_to_major` = `T2`.`major_id` WHERE `T1`.`first_name` = 'Angela' AND `T1`.`last_name` = 'Sanders'
simple
1,317
student_club
Among the students from the Student_Club who attended the event "Women's Soccer", how many of them want a T-shirt that's in medium size?
Women's Soccer is an event name; T-shirt that is in medium size refers to t_shirt_size = 'Medium'
SELECT COUNT(`T1`.`event_id`) FROM `event` AS `T1` INNER JOIN `attendance` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` INNER JOIN `member` AS `T3` ON `T2`.`link_to_member` = `T3`.`member_id` WHERE `T1`.`event_name` = 'Women''s Soccer' AND `T3`.`t_shirt_size` = 'Medium'
moderate
1,322
student_club
Among the events attended by more than 10 members of the Student_Club, how many of them are meetings?
meetings events refers to type = 'Meeting'; attended by more than 10 members refers to COUNT(event_id) > 10
SELECT COUNT(DISTINCT T1.event_id) FROM event AS T1 INNER JOIN attendance AS T2 ON T1.event_id = T2.link_to_event WHERE T1.type = 'Meeting' GROUP BY T1.event_id HAVING COUNT(T2.link_to_event) > 10
moderate
1,323
student_club
List all the names of events that had an attendance of over 20 students but were not fundraisers.
name of events refers to event_name; attendance of over 20 students COUNT(event_id) > 20.
SELECT `T1`.`event_name` FROM `event` AS `T1` INNER JOIN `attendance` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` GROUP BY `T1`.`event_id` HAVING COUNT(`T2`.`link_to_event`) > 20 AND NOT EXISTS (SELECT 1 FROM `event` AS `E` WHERE `E`.`event_id` = `T1`.`event_id` AND `E`.`type` = 'Fundraiser')
moderate
1,331
student_club
What is the amount of the funds that the Vice President received?
'Vice President' is a position of Student Club; funds received refers to amount.
SELECT `T2`.`amount` FROM `member` AS `T1` INNER JOIN `income` AS `T2` ON `T1`.`member_id` = `T2`.`link_to_member` WHERE `T1`.`position` = 'Vice President'
simple
1,334
student_club
List the full name of the Student_Club members that grew up in Illinois state.
full name of member refers to first_name, last_name
SELECT `T1`.`first_name`, `T1`.`last_name` FROM `member` AS `T1` INNER JOIN `zip_code` AS `T2` ON `T1`.`zip` = `T2`.`zip_code` WHERE `T2`.`state` = 'Illinois'
simple
1,338
student_club
Was each expense in October Meeting on October 8, 2019 approved?
event_name = 'October Meeting' where event_date = '2019-10-08'; approved = True means expenses was approved; approved = False means expenses was not approved
SELECT `T3`.`approved` FROM `event` AS `T1` INNER JOIN `budget` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` INNER JOIN `expense` AS `T3` ON `T2`.`budget_id` = `T3`.`link_to_budget` WHERE `T1`.`event_name` = 'October Meeting' AND `T1`.`event_date` LIKE '2019-10-08%'
moderate
1,339
student_club
Calculate the total average cost that Elijah Allen spent in the events on September and October.
Elijah Allen is the full name; full name refers to first_name, last_name; The 5th and 6th string of the expense_date in the expense table can refer to month; events in September and October refers to month(expense_date) = 9 OR month(expense_date) = 10
SELECT AVG(`T2`.`cost`) FROM `member` AS `T1` INNER JOIN `expense` AS `T2` ON `T1`.`member_id` = `T2`.`link_to_member` WHERE `T1`.`last_name` = 'Allen' AND `T1`.`first_name` = 'Elijah' AND ( SUBSTR(`T2`.`expense_date`, 6, 2) = '09' OR SUBSTR(`T2`.`expense_date`, 6, 2) = '10' )
challenging
1,340
student_club
Calculate the difference of the total amount spent in all events by the Student_Club in year 2019 and 2020.
The first 4 strings of the event_date values in the event table can represent year; The difference of the total amount spent = SUBTRACT(spent where YEAR(event_date) = 2019, spent where YEAR(event_date) = 2020)
SELECT SUM(CASE WHEN SUBSTR(`T1`.`event_date`, 1, 4) = '2019' THEN `T2`.`spent` ELSE 0 END) - SUM(CASE WHEN SUBSTR(`T1`.`event_date`, 1, 4) = '2020' THEN `T2`.`spent` ELSE 0 END) AS `num` FROM `event` AS `T1` INNER JOIN `budget` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event`
moderate
1,344
student_club
What was the notes of the fundraising on 2019/9/14?
fundraising on 2019/9/14 refers to source = 'Fundraising' where date_received = '2019-09-14'
SELECT `notes` FROM `income` WHERE `source` = 'Fundraising' AND `date_received` = '2019-09-14'
simple
1,346
student_club
Tell the phone number of "Carlo Jacobs".
Carlo Jacobs is the full name; full name refers to first_name, last_name;
SELECT `phone` FROM `member` WHERE `first_name` = 'Carlo' AND `last_name` = 'Jacobs'
simple
1,350
student_club
What is the status of the event which bought "Post Cards, Posters" on 2019/8/20?
'Post Cards, Posters' is an expense description; on 2019/8/20 refers to expense_date = '2019-8-20'; status of event refers to event_status
SELECT `T1`.`event_status` FROM `budget` AS `T1` INNER JOIN `expense` AS `T2` ON `T1`.`budget_id` = `T2`.`link_to_budget` WHERE `T2`.`expense_description` = 'Post Cards, Posters' AND `T2`.`expense_date` = '2019-08-20'
moderate
1,351
student_club
What was Brent Thomason's major?
Brent Thomason is the full name; full name refers to first_name, last_name; major refers to major_name
SELECT `T2`.`major_name` FROM `member` AS `T1` INNER JOIN `major` AS `T2` ON `T1`.`link_to_major` = `T2`.`major_id` WHERE `T1`.`first_name` = 'Brent' AND `T1`.`last_name` = 'Thomason'
simple
1,352
student_club
For all the club members from "Business" major, how many of them wear medium size t-shirt?
'Business' is a major name; wear medium size t-shirt refers to t_shirt_size = 'Medium'
SELECT COUNT(`T1`.`member_id`) FROM `member` AS `T1` INNER JOIN `major` AS `T2` ON `T1`.`link_to_major` = `T2`.`major_id` WHERE `T2`.`major_name` = 'Business' AND `T1`.`t_shirt_size` = 'Medium'
moderate
1,356
student_club
Which department was the President of the club in?
'President' is a position of Student Club
SELECT `T2`.`department` FROM `member` AS `T1` INNER JOIN `major` AS `T2` ON `T1`.`link_to_major` = `T2`.`major_id` WHERE `T1`.`position` = 'President'
simple
1,357
student_club
State the date Connor Hilton paid his/her dues.
Connor Hilton is the full name; full name refers to first_name, last_name; date the dues was paid refers to date_received where source = 'Dues';
SELECT `T2`.`date_received` FROM `member` AS `T1` INNER JOIN `income` AS `T2` ON `T1`.`member_id` = `T2`.`link_to_member` WHERE `T1`.`first_name` = 'Connor' AND `T1`.`last_name` = 'Hilton' AND `T2`.`source` = 'Dues'
simple
1,359
student_club
How many times was the budget in Advertisement for "Yearly Kickoff" meeting more than "October Meeting"?
budget in Advertisement refer to category = 'Advertisement' in the budget table; DIVIDE(SUM(amount when event_name = 'Yearly Kickoff'), SUM(amount when event_name = 'October Meeting'))
SELECT CAST(SUM(CASE WHEN `T2`.`event_name` = 'Yearly Kickoff' THEN `T1`.`amount` ELSE 0 END) AS DOUBLE) / SUM(CASE WHEN `T2`.`event_name` = 'October Meeting' THEN `T1`.`amount` ELSE 0 END) FROM `budget` AS `T1` INNER JOIN `event` AS `T2` ON `T1`.`link_to_event` = `T2`.`event_id` WHERE `T1`.`category` = 'Advertisement' AND `T2`.`type` = 'Meeting'
challenging
1,361
student_club
What is the total cost of the pizzas for all the events?
total cost of the pizzas refers to SUM(cost) where expense_description = 'Pizza'
SELECT SUM(`cost`) FROM `expense` WHERE `expense_description` = 'Pizza'
simple
1,362
student_club
How many cities are there in Orange County, Virginia?
Orange County is the county name, Virginia is the state name
SELECT COUNT(`city`) FROM `zip_code` WHERE `county` = 'Orange County' AND `state` = 'Virginia'
simple
1,368
student_club
What does the person with the phone number "809-555-3360" major in?
major in refers to major_name
SELECT `T2`.`major_name` FROM `member` AS `T1` INNER JOIN `major` AS `T2` ON `T1`.`link_to_major` = `T2`.`major_id` WHERE `T1`.`phone` = '809-555-3360'
simple
1,371
student_club
How many members attended the "Women's Soccer" event?
'Women's Soccer' is the event name;
SELECT COUNT(`T2`.`link_to_member`) FROM `event` AS `T1` INNER JOIN `attendance` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` WHERE `T1`.`event_name` = 'Women''s Soccer'
simple
1,375
student_club
List all the members of the "School of Applied Sciences, Technology and Education" department.
list all members means to list all the full name; full name refers to first_name, last_name;
SELECT `T1`.`first_name`, `T1`.`last_name` FROM `member` AS `T1` INNER JOIN `major` AS `T2` ON `T1`.`link_to_major` = `T2`.`major_id` WHERE `T2`.`department` = 'School of Applied Sciences, Technology and Education'
moderate
1,376
student_club
Among all the closed events, which event has the highest spend-to-budget ratio?
closed events refers to event_name where status = 'Closed'; highest spend-to budget ratio refers to MAX(DIVIDE(spent, amount))
SELECT `T2`.`event_name` FROM `budget` AS `T1` INNER JOIN `event` AS `T2` ON `T1`.`link_to_event` = `T2`.`event_id` WHERE `T2`.`status` = 'Closed' ORDER BY `T1`.`spent` / `T1`.`amount` DESC LIMIT 1
moderate
1,378
student_club
What is the highest amount of budget spend for an event?
highest amount of budget spend refers to MAX(spent)
SELECT MAX(`spent`) FROM `budget`
simple
1,380
student_club
What is the total amount of money spent for food?
total amount of money spent refers to SUM(spent); spent for food refers to category = 'Food'
SELECT SUM(spent) FROM budget WHERE category = 'Food'
simple
1,381
student_club
List the name of students that have attended more than 7 events.
name of students means the full name; full name refers to first_name, last_name; attended more than 7 events refers to COUNT(link_to_event) > 7
SELECT `T1`.`first_name`, `T1`.`last_name` FROM `member` AS `T1` INNER JOIN `attendance` AS `T2` ON `T1`.`member_id` = `T2`.`link_to_member` GROUP BY `T2`.`link_to_member` HAVING COUNT(`T2`.`link_to_event`) > 7
moderate
1,387
student_club
Which student has been entrusted to manage the budget for the Yearly Kickoff?
name of students means the full name; full name refers to first_name, last_name;'Yearly Kickoff' is an event name;
SELECT `T4`.`first_name`, `T4`.`last_name` FROM `event` AS `T1` INNER JOIN `budget` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` INNER JOIN `expense` AS `T3` ON `T2`.`budget_id` = `T3`.`link_to_budget` INNER JOIN `member` AS `T4` ON `T3`.`link_to_member` = `T4`.`member_id` WHERE `T1`.`event_name` = 'Yearly Kickoff'
moderate
1,389
student_club
Which event has the lowest cost?
event refers to event_name; lowest cost means MIN(cost)
SELECT `T1`.`event_name` FROM `event` AS `T1` INNER JOIN `budget` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` INNER JOIN `expense` AS `T3` ON `T2`.`budget_id` = `T3`.`link_to_budget` ORDER BY `T3`.`cost` LIMIT 1
simple
1,390
student_club
Based on the total cost for all event, what is the percentage of cost for Yearly Kickoff event?
percentage = DIVIDE(SUM(cost where event_name = 'Yearly Kickoff'), SUM(cost)) * 100
SELECT CAST(SUM(CASE WHEN `T1`.`event_name` = 'Yearly Kickoff' THEN `T3`.`cost` ELSE 0 END) AS DOUBLE) * 100 / SUM(`T3`.`cost`) FROM `event` AS `T1` INNER JOIN `budget` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` INNER JOIN `expense` AS `T3` ON `T2`.`budget_id` = `T3`.`link_to_budget`
moderate
1,392
student_club
Indicate the top source of funds received in September 2019 based on their amount.
top source funds refers to MAX(source); September 2019 means date_received BETWEEN '2019-09-01' and '2019-09-30'
SELECT `source` FROM `income` WHERE `date_received` BETWEEN '2019-09-01' AND '2019-09-30' ORDER BY `source` DESC LIMIT 1
simple
1,394
student_club
How many members of the Student_Club have major in 'Physics Teaching'?
'Physics Teaching' is the major_name;
SELECT COUNT(`T2`.`member_id`) FROM `major` AS `T1` INNER JOIN `member` AS `T2` ON `T1`.`major_id` = `T2`.`link_to_major` WHERE `T1`.`major_name` = 'Physics Teaching'
simple
1,398
student_club
Name the event with the highest amount spent on advertisement.
Name of event refers to event_name; highest amount spent on advertisement refers to MAX(spent) where category = 'Advertisement'
SELECT `T2`.`event_name` FROM `budget` AS `T1` INNER JOIN `event` AS `T2` ON `T1`.`link_to_event` = `T2`.`event_id` WHERE `T1`.`category` = 'Advertisement' ORDER BY `T1`.`spent` DESC LIMIT 1
moderate
1,399
student_club
Did Maya Mclean attend the 'Women's Soccer' event?
Maya Mclean is the full name; full name refers to first_name, last_name; 'Women's Soccer' is an event_name
SELECT CASE WHEN `T3`.`event_name` = 'Women''s Soccer' THEN 'YES' END AS `result` FROM `member` AS `T1` INNER JOIN `attendance` AS `T2` ON `T1`.`member_id` = `T2`.`link_to_member` INNER JOIN `event` AS `T3` ON `T2`.`link_to_event` = `T3`.`event_id` WHERE `T1`.`first_name` = 'Maya' AND `T1`.`last_name` = 'Mclean'
moderate
1,401
student_club
Indicate the cost of posters for 'September Speaker' event.
'Posters' is the expense description; 'September Speaker' is an event name
SELECT `T3`.`cost` FROM `event` AS `T1` INNER JOIN `budget` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` INNER JOIN `expense` AS `T3` ON `T2`.`budget_id` = `T3`.`link_to_budget` WHERE `T1`.`event_name` = 'September Speaker' AND `T3`.`expense_description` = 'Posters'
moderate
1,403
student_club
Indicate the name of the closed event whose cost has exceeded the budget the most.
closed events refers to event_name where status = 'Closed'; exceed the budget the most refers to MIN(remaining) where remaining < 0
SELECT `T2`.`event_name` FROM `budget` AS `T1` INNER JOIN `event` AS `T2` ON `T2`.`event_id` = `T1`.`link_to_event` WHERE `T1`.`event_status` = 'Closed' AND `T1`.`remaining` < 0 ORDER BY `T1`.`remaining` LIMIT 1
moderate
1,404
student_club
Identify the type of expenses and their total value approved for 'October Meeting' event.
total value refers to SUM(cost); 'October Meeting' is an event name;
SELECT `T1`.`type`, SUM(`T3`.`cost`) AS `total_cost` FROM `event` AS `T1` INNER JOIN `budget` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` INNER JOIN `expense` AS `T3` ON `T2`.`budget_id` = `T3`.`link_to_budget` WHERE `T1`.`event_name` = 'October Meeting' GROUP BY `T1`.`type`
moderate
1,405
student_club
Calculate the amount budgeted for 'April Speaker' event. List all the budgeted categories for said event in an ascending order based on their amount budgeted.
'April Speaker' is an event name; amount budgeted refers to SUM(amount); budget categories refers to category
SELECT T2.category, SUM(T2.amount) FROM event AS T1 INNER JOIN budget AS T2 ON T1.event_id = T2.link_to_event WHERE T1.event_name = 'April Speaker' GROUP BY T2.category ORDER BY SUM(T2.amount) ASC
moderate
1,409
student_club
Mention the total expense used on 8/20/2019.
total expense refers SUM(cost) where expense_date = '2019-08-20'
SELECT SUM(`cost`) FROM `expense` WHERE `expense_date` = '2019-08-20'
simple
1,410
student_club
List out the full name and total cost that member id "rec4BLdZHS2Blfp4v" incurred?
full name refers to first_name, last name
SELECT `T1`.`first_name`, `T1`.`last_name`, SUM(`T2`.`cost`) FROM `member` AS `T1` INNER JOIN `expense` AS `T2` ON `T1`.`member_id` = `T2`.`link_to_member` WHERE `T1`.`member_id` = 'rec4BLdZHS2Blfp4v'
simple
1,411
student_club
State what kind of expenses that Sacha Harrison incurred?
kind of expenses refers to expense_description; Sacha Harrison is the full name; full name refers to first_name, last_name;
SELECT `T2`.`expense_description` FROM `member` AS `T1` INNER JOIN `expense` AS `T2` ON `T1`.`member_id` = `T2`.`link_to_member` WHERE `T1`.`first_name` = 'Sacha' AND `T1`.`last_name` = 'Harrison'
simple
1,422
student_club
State the category of events were held at MU 215.
'MU 215' is the location of event;
SELECT DISTINCT `T2`.`category` FROM `event` AS `T1` INNER JOIN `budget` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` WHERE `T1`.`location` = 'MU 215'
simple
1,426
student_club
List the last name of members with a major in environmental engineering and include its department and college name.
'Environmental Engineering' is the major_name;
SELECT `T2`.`last_name`, `T1`.`department`, `T1`.`college` FROM `major` AS `T1` INNER JOIN `member` AS `T2` ON `T1`.`major_id` = `T2`.`link_to_major` WHERE `T2`.`position` = 'Member' AND `T1`.`major_name` = 'Environmental Engineering'
moderate
1,427
student_club
What are the budget category of the events located at MU 215 and a guest speaker type with a 0 budget spent?
budget category refers to category; events located at refers to location; type = 'Guest Speaker'; 0 budget spent refers to spent = 0;
SELECT DISTINCT `T2`.`category`, `T1`.`type` FROM `event` AS `T1` INNER JOIN `budget` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` WHERE `T1`.`location` = 'MU 215' AND `T2`.`spent` = 0 AND `T1`.`type` = 'Guest Speaker'
moderate
1,432
student_club
Among the members with t-shirt size of medium, what is the percentage of the amount 50 received by the Student_Club?
t_shirt_size = 'Medium' where position = 'Member'; percentage = DIVIDE(COUNT(amount = 50), COUNT(member_id)) * 100
SELECT CAST(SUM(CASE WHEN `T2`.`amount` = 50 THEN 1.0 ELSE 0 END) AS DOUBLE) * 100 / COUNT(`T2`.`income_id`) FROM `member` AS `T1` INNER JOIN `income` AS `T2` ON `T1`.`member_id` = `T2`.`link_to_member` WHERE `T1`.`position` = 'Member' AND `T1`.`t_shirt_size` = 'Medium'
moderate
1,435
student_club
List the names of closed event as "game" that was closed from 3/15/2019 to 3/20/2020.
name of events refers event_name; game event that was closed refers to type = 'Game' where status = 'Closed'; event_date BETWEEN '2019-03-15' and '2020-03-20';
SELECT DISTINCT `event_name` FROM `event` WHERE `type` = 'Game' AND DATE(SUBSTR(`event_date`, 1, 10)) BETWEEN '2019-03-15' AND '2020-03-20' AND `status` = 'Closed'
moderate
1,457
student_club
Give the full name and contact number of members who had to spend more than average on each expense.
full name refers to first_name, last_name; contact number refers to phone; had spent more than average on each expense refers to cost > AVG(cost)
SELECT DISTINCT `T3`.`first_name`, `T3`.`last_name`, `T3`.`phone` FROM `expense` AS `T1` INNER JOIN `budget` AS `T2` ON `T1`.`link_to_budget` = `T2`.`budget_id` INNER JOIN `member` AS `T3` ON `T3`.`member_id` = `T1`.`link_to_member` WHERE `T1`.`cost` > ( SELECT AVG(`T1`.`cost`) FROM `expense` AS `T1` INNER JOIN `budget` AS `T2` ON `T1`.`link_to_budget` = `T2`.`budget_id` INNER JOIN `member` AS `T3` ON `T3`.`member_id` = `T1`.`link_to_member` )
challenging
1,460
student_club
Write the full name of the member who spent money for water, veggie tray and supplies and include the cost of it.
full name refers to first_name, last name; spent money for refers expense description; expense_description = 'Water, Veggie tray, supplies'
SELECT `T2`.`first_name`, `T2`.`last_name`, `T1`.`cost` FROM `expense` AS `T1` INNER JOIN `member` AS `T2` ON `T1`.`link_to_member` = `T2`.`member_id` WHERE `T1`.`expense_description` = 'Water, Veggie tray, supplies'
challenging
1,464
student_club
Write the full names of students who received funds on the date of 9/9/2019 and include the amount received.
full name refers to first_name, last_name, amount of funds received refers to amount, received funds on date refers to date_received
SELECT DISTINCT `T3`.`first_name`, `T3`.`last_name`, `T4`.`amount` FROM `event` AS `T1` INNER JOIN `attendance` AS `T2` ON `T1`.`event_id` = `T2`.`link_to_event` INNER JOIN `member` AS `T3` ON `T3`.`member_id` = `T2`.`link_to_member` INNER JOIN `income` AS `T4` ON `T4`.`link_to_member` = `T3`.`member_id` WHERE `T4`.`date_received` = '2019-09-09'
challenging
1,149
thrombosis_prediction
Are there more in-patient or outpatient who were male? What is the deviation in percentage?
male refers to SEX = 'M'; in-patient refers to Admission = '+'; outpatient refers to Admission = '-'; percentage = DIVIDE(COUNT(ID) where SEX = 'M' and Admission = '+', COUNT(ID) where SEX  = 'M' and Admission = '-')
SELECT CAST(SUM(CASE WHEN `Admission` = '+' THEN 1 ELSE 0 END) AS DOUBLE) * 100 / SUM(CASE WHEN `Admission` = '-' THEN 1 ELSE 0 END) FROM `Patient` WHERE `SEX` = 'M'
moderate
1,150
thrombosis_prediction
What is the percentage of female patient were born after 1930?
female refers to Sex = 'F'; patient who were born after 1930 refers to year(Birthday) > '1930'; calculation = DIVIDE(COUNT(ID) where year(Birthday) > '1930' and SEX = 'F'), (COUNT(ID) where SEX = 'F')
SELECT CAST(SUM( CASE WHEN DATE_FORMAT(CAST(`Birthday` AS DATETIME), '%Y') > '1930' THEN 1 ELSE 0 END ) AS DOUBLE) * 100 / COUNT(*) FROM `Patient` WHERE `SEX` = 'F'
moderate
1,152
thrombosis_prediction
What is the ratio of outpatient to inpatient followed up treatment among all the 'SLE' diagnosed patient?
'SLE' diagnosed patient means Diagnosis = 'SLE'; inpatient refers to Admission = '+'; outpatient refers to Admission = '-'; calculation = DIVIDE(COUNT(ID) where Diagnosis = 'SLE' and Admission = '+', COUNT(ID) where Diagnosis = 'SLE' and Admission = '-')
SELECT SUM(CASE WHEN `Admission` = '+' THEN 1 ELSE 0 END) / SUM(CASE WHEN `Admission` = '-' THEN 1 ELSE 0 END) FROM `Patient` WHERE `Diagnosis` = 'SLE'
moderate
1,153
thrombosis_prediction
What is the disease patient '30609' diagnosed with. List all the date of laboratory tests done for this patient.
'30609' is the Patient ID; disease means Diagnosis
SELECT `T1`.`Diagnosis`, `T2`.`Date` FROM `Patient` AS `T1` INNER JOIN `Laboratory` AS `T2` ON `T1`.`ID` = `T2`.`ID` WHERE `T1`.`ID` = 30609
simple
1,155
thrombosis_prediction
List the patient ID, sex and birthday of patient with LDH beyond normal range.
LDH beyond normal range refers to LDH > '500';
SELECT DISTINCT `T1`.`ID`, `T1`.`SEX`, `T1`.`Birthday` FROM `Patient` AS `T1` INNER JOIN `Laboratory` AS `T2` ON `T1`.`ID` = `T2`.`ID` WHERE `T2`.`LDH` > 500
simple
1,156
thrombosis_prediction
State the ID and age of patient with positive degree of coagulation.
age refers to SUBTRACT(year(current_timestamp), year(Birthday)); positive degree of coagulation refers to RVVT = '+';
SELECT DISTINCT `T1`.`ID`, DATE_FORMAT(CAST(CURRENT_TIMESTAMP() AS DATETIME), '%Y') - DATE_FORMAT(CAST(`T1`.`Birthday` AS DATETIME), '%Y') FROM `Patient` AS `T1` INNER JOIN `Examination` AS `T2` ON `T1`.`ID` = `T2`.`ID` WHERE `T2`.`RVVT` = '+'
moderate
1,157
thrombosis_prediction
For patients with severe degree of thrombosis, list their ID, sex and disease the patient is diagnosed with.
severe degree of thrombosis refers to thrombosis = 2; disease refers to diagnosis;
SELECT DISTINCT `T1`.`ID`, `T1`.`SEX`, `T1`.`Diagnosis` FROM `Patient` AS `T1` INNER JOIN `Examination` AS `T2` ON `T1`.`ID` = `T2`.`ID` WHERE `T2`.`Thrombosis` = 2
simple
1,162
thrombosis_prediction
How many female patients who came at the hospital in 1997 was immediately followed at the outpatient clinic?
female refers to sex = 'F'; came at the hospital in 1997 refers to year(Description) = '1997'; immediately followed at the outpatient clinic refers to Admission = '-'
SELECT COUNT(*) FROM `Patient` WHERE DATE_FORMAT(CAST(`Description` AS DATETIME), '%Y') = '1997' AND `SEX` = 'F' AND `Admission` = '-'
moderate
1,164
thrombosis_prediction
How many of the patients with the most serious thrombosis cases examined in 1997 are women?
the most serious thrombosis refers to Thrombosis = '1' (the most severe one); women refers to sex = 'F'
SELECT COUNT(*) FROM `Patient` AS `T1` INNER JOIN `Examination` AS `T2` ON `T1`.`ID` = `T2`.`ID` WHERE `T1`.`SEX` = 'F' AND DATE_FORMAT(CAST(`T2`.`Examination Date` AS DATETIME), '%Y') = '1997' AND `T2`.`Thrombosis` = 1
moderate
1,166
thrombosis_prediction
What are the symptoms observed by the youngest patient to ever did a medical examination? Identify their diagnosis.
The larger the birthday value, the younger the person is, and vice versa; symptoms observed refers to the symptoms is not NULL
SELECT `T2`.`Symptoms`, `T1`.`Diagnosis` FROM `Patient` AS `T1` INNER JOIN `Examination` AS `T2` ON `T1`.`ID` = `T2`.`ID` WHERE NOT `T2`.`Symptoms` IS NULL ORDER BY `T1`.`Birthday` DESC LIMIT 1
simple
1,168
thrombosis_prediction
The oldest SJS patient's medical laboratory work was completed on what date, and what age was the patient when they initially arrived at the hospital?
The larger the birthday value, the younger the person is, and vice versa; 'SJS' refers to diagnosis; (SUBTRACT(year(`First Date`)), year(Birthday)); age of the patients when they initially arrived at the hospital refers to year(Birthday)
SELECT `T1`.`Date`, DATE_FORMAT(CAST(`T2`.`First Date` AS DATETIME), '%Y') - DATE_FORMAT(CAST(`T2`.`Birthday` AS DATETIME), '%Y'), `T2`.`Birthday` FROM `Laboratory` AS `T1` INNER JOIN `Patient` AS `T2` ON `T1`.`ID` = `T2`.`ID` WHERE `T2`.`Diagnosis` = 'SJS' AND NOT `T2`.`Birthday` IS NULL ORDER BY `T2`.`Birthday` ASC LIMIT 1
challenging
1,169
thrombosis_prediction
What is the ratio of male to female patients among all those with abnormal uric acid counts?
male refers to SEX = 'M'; female refers to SEX = 'F'; abnormal uric acid refers to UA < = '8.0' where SEX = 'M', UA < = '6.5' where SEX = 'F'; calculation = DIVIDE(SUM(UA <= '8.0' and SEX = 'M'), SUM(UA <= '6.5 and SEX = 'F'))
SELECT CAST(SUM(CASE WHEN `T2`.`UA` <= 8.0 AND `T1`.`SEX` = 'M' THEN 1 ELSE 0 END) AS DOUBLE) / SUM(CASE WHEN `T2`.`UA` <= 6.5 AND `T1`.`SEX` = 'F' THEN 1 ELSE 0 END) FROM `Patient` AS `T1` INNER JOIN `Laboratory` AS `T2` ON `T1`.`ID` = `T2`.`ID`
challenging
1,171
thrombosis_prediction
How many underage patients were examined during the course of the three-year period from 1990 to 1993?
underage patients refers to year(Birthday) < 18; three-year period from 1990 to 1993 refers to year(`Examination Date`) between '1990' and '1993'
SELECT COUNT(`T1`.`ID`) FROM `Patient` AS `T1` INNER JOIN `Examination` AS `T2` ON `T1`.`ID` = `T2`.`ID` WHERE DATE_FORMAT(CAST(`T2`.`Examination Date` AS DATETIME), '%Y') BETWEEN '1990' AND '1993' AND DATE_FORMAT(CAST(`T2`.`Examination Date` AS DATETIME), '%Y') - DATE_FORMAT(CAST(`T1`.`Birthday` AS DATETIME), '%Y') < '18'
challenging
1,175
thrombosis_prediction
How old was the patient who had the highest hemoglobin count at the time of the examination, and what is the doctor's diagnosis?
How old the patient refers to SUBTRACT(year(`Examination Date`), year(Birthday)); the highest hemoglobin count refers to MAX(HGB)
SELECT DATE_FORMAT(CAST(`T2`.`Date` AS DATETIME), '%Y') - DATE_FORMAT(CAST(`T1`.`Birthday` AS DATETIME), '%Y'), `T1`.`Diagnosis` FROM `Patient` AS `T1` INNER JOIN `Laboratory` AS `T2` ON `T1`.`ID` = `T2`.`ID` ORDER BY `T2`.`HGB` DESC LIMIT 1
moderate
1,179
thrombosis_prediction
For the patient who was diagnosed with SLE on 1994/2/19, what was his/her anti-Cardiolipin antibody concentration status on 1993/11/12?
diagnosed with SLE refers to Diagnosis = 'SLE'; 1994/2/19 refers to Description = '1994-02-19'; anti-Cardiolipin refers to aCL IgM; 1993/11/12 refers to Examination Date = '1993/11/12'
SELECT `aCL IgA`, `aCL IgG`, `aCL IgM` FROM `Examination` WHERE `ID` IN ( SELECT `ID` FROM `Patient` WHERE `Diagnosis` = 'SLE' AND `Description` = '1994-02-19' ) AND `Examination Date` = '1993-11-12'
moderate
1,185
thrombosis_prediction
For the patient who was born on 1959/2/18, what is the decrease rate for his/her total cholesterol from November to December in 1981?
born on 1959/2/18 refers to Birthday = '1959-02-18'; calculation = DIVISION(SUBTRACT(SUM(Birthday = '1959-02-18' and Date like '1981-11-%' THEN `T-CHO`), SUM(Birthday = '1959-02-18' and Date like '1981-12-%' THEN `T-CHO`)), SUM(Birthday = '1959-02-18' and Date like '1981-12-%' THEN `T-CHO`))
SELECT CAST(( SUM(CASE WHEN `T2`.`Date` LIKE '1981-11-%' THEN `T2`.`T-CHO` ELSE 0 END) - SUM(CASE WHEN `T2`.`Date` LIKE '1981-12-%' THEN `T2`.`T-CHO` ELSE 0 END) ) AS DOUBLE) / SUM(CASE WHEN `T2`.`Date` LIKE '1981-12-%' THEN `T2`.`T-CHO` ELSE 0 END) FROM `Patient` AS `T1` INNER JOIN `Laboratory` AS `T2` ON `T1`.`ID` = `T2`.`ID` WHERE `T1`.`Birthday` = '1959-02-18'
challenging
1,187
thrombosis_prediction
How many patients who were examined between 1987/7/6 and 1996/1/31 had a GPT level greater than 30 and an ALB level less than 4? List them by their ID.
examined between 1987/7/6 and 1996/1/31 refers to Date BETWEEN '1987-07-06' AND '1996-01-31'; GPT level greater than 30 refers to GPT > 30; ALB level less than 4 ALB < 4
SELECT DISTINCT `ID` FROM `Laboratory` WHERE `Date` BETWEEN '1987-07-06' AND '1996-01-31' AND `GPT` > 30 AND `ALB` < 4
moderate
1,189
thrombosis_prediction
What number of patients with a degree of thrombosis level 2 and ANA pattern of only S, have a level of anti-Cardiolip in antibody (IgM) 20% higher than average?
thrombosis level 2 refers to Thrombosis = 2; ANA pattern of only S refers to ANA = 'S'; average anti-Cardiolip in antibody (IgM) refers to AVG(`aCL IgM`); calculation = MULTIPLY(AVG + AVG, 0.2)
SELECT COUNT(*) FROM `Examination` WHERE `Thrombosis` = 2 AND `ANA Pattern` = 'S' AND `aCL IgM` > ( SELECT AVG(`aCL IgM`) * 1.2 FROM `Examination` WHERE `Thrombosis` = 2 AND `ANA Pattern` = 'S' )
challenging
1,192
thrombosis_prediction
List all patients who were followed up at the outpatient clinic who underwent a laboratory test in October 1991 and had a total blood bilirubin level within the normal range.
followed up at the outpatient clinic refers to Admission = '-'; laboratory test in April 1981 refers to Date like '1991-10%'; blood bilirubin level within the normal range refers to T-BIL < 2.0;
SELECT DISTINCT `T1`.`ID` FROM `Patient` AS `T1` INNER JOIN `Laboratory` AS `T2` ON `T1`.`ID` = `T2`.`ID` WHERE `T1`.`Admission` = '-' AND `T2`.`T-BIL` < 2.0 AND `T2`.`Date` LIKE '1991-10-%'
challenging
1,195
thrombosis_prediction
What is the average blood albumin level for female patients with a PLT greater than 400 who have been diagnosed with SLE?
average blood albumin level refers to AVG(ALB); female refers to SEX = 'F'; PLT greater than 400 refers to PLT > 400; diagnosed with SLE refers to Diagnosis= 'SLE'
SELECT AVG(`T2`.`ALB`) FROM `Patient` AS `T1` INNER JOIN `Laboratory` AS `T2` ON `T1`.`ID` = `T2`.`ID` WHERE `T2`.`PLT` > 400 AND `T1`.`Diagnosis` = 'SLE' AND `T1`.`SEX` = 'F'
moderate
1,198
thrombosis_prediction
How many female patients were given an APS diagnosis?
female refers to SEX = 'F'; APS diagnosis refers to Diagnosis='APS'
SELECT COUNT(`ID`) FROM `Patient` WHERE `SEX` = 'F' AND `Diagnosis` = 'APS'
simple
1,201
thrombosis_prediction
What percentage of patients who were born in 1980 and were diagnosed with RA are women?
born in 1980 refers to YEAR(BIRTHDAY) = '1980'; 'RA' refers to Diagnosis='RA' ; women refers to SEX = 'F'; calculation = DIVIDE(SUM(SEX = 'F'), COUNT(SEX)) * 100
SELECT CAST(SUM(CASE WHEN `SEX` = 'F' THEN 1 ELSE 0 END) AS DOUBLE) * 100 / COUNT(`ID`) FROM `Patient` WHERE `Diagnosis` = 'RA' AND DATE_FORMAT(CAST(`Birthday` AS DATETIME), '%Y') = '1980'
moderate
End of preview. Expand in Data Studio

BIRD-SQL Mini-Dev

Update 2025-07-04

We are grateful for the valuable feedback from the community over the past year regarding BIRD Mini-Dev. Based on your suggestions, we have made significant updates to the BIRD Mini-Dev dataset.

For New Users

If you are new to BIRD Mini-Dev, you can download the complete databases and datasets using the following link: Download BIRD Mini-Dev Complete Package

For Existing Users

If you have already downloaded the BIRD databases, you can pull the latest data updates through Hugging Face using the following scripts:

from datasets import load_dataset

# Load the dataset
dataset = load_dataset("birdsql/bird_mini_dev")

# Access the SQLite version
print(dataset["mini_dev_sqlite"][0])

# Access the MySQL version
print(dataset["mini_dev_mysql"][0])

# Access the PostgreSQL version
print(dataset["mini_dev_pg"][0])

We appreciate the continuous support and feedback from the community.

Overview

Here, we provide a Lite version of developtment dataset: Mini-Dev. This mini-dev dataset is designed to facilitate efficient and cost-effective development cycles, especially for testing and refining SQL query generation models. This dataset results from community feedback, leading to the compilation of 500 high-quality text2sql pairs derived from 11 distinct databases in a development environment. To further enhance the practicality of the BIRD system in industry settings and support the development of text-to-SQL models, we make the Mini-Dev dataset available in both MySQL and PostgreSQL.

Additionally, we introduce two new evaluation metrics for the Mini-Dev dataset: the Reward-based Valid Efficiency Score (R-VES) and the Soft F1-Score. These metrics aim to evaluate the efficiency and accuracy of text-to-SQL models, respectively. It is important to note that the both metrics, currently in their beta version, applies exclusively to the Mini-Dev dataset using baseline models.

We welcome contributions and suggestions for enhancing these metrics, particularly regarding their integration into existing leaderboards. Please do not hesitate to contact us if you are interested in these developments or have any proposals for improvements.

Below are some key statistics of the mini-dev dataset:

Difficulty Distribution

  • Simple: 30%
  • Moderate: 50%
  • Challenging: 20%

Database Distribution

  • Debit Card Specializing: 30 instances
  • Student Club: 48 instances
  • Thrombosis Prediction: 50 instances
  • European Football 2: 51 instances
  • Formula 1: 66 instances
  • Superhero: 52 instances
  • Codebase Community: 49 instances
  • Card Games: 52 instances
  • Toxicology: 40 instances
  • California Schools: 30 instances
  • Financial: 32 instances

Keywords Statistic

  • Main Body Keywords •SELECT •FROM •WHERE •AND •OR •NOT •IN •EXISTS •IS •NULL •IIF •CASE •CASE WHEN.
  • Join Keywords • INNER JOIN • LEFT JOIN • ON • AS.
  • Clause Keywords • BETWEEN • LIKE • LIMIT • ORDER BY • ASC • DESC • GROUP BY •HAVING •UNION •ALL •EXCEPT •PARTITION BY •OVER.
  • Aggregation Keywords • AVG • COUNT • MAX • MIN • ROUND • SUM.
  • Scalar Keywords • ABS • LENGTH • STRFTIME • JULIADAY • NOW • CAST • SUBSTR • INSTR.
  • Comparison Keywords •= •> •< •>= •<= •!=.
  • Computing Keywords •- •+ •* •/.

Dataset Introduction

The dataset contains the main following resources:

  • database: The database should be stored under the ./mini_dev_data/dev_databases/. In each database folder, it has two components:
    • database_description: the csv files are manufactured to describe database schema and its values for models to explore or references.
    • sqlite: The database contents in BIRD.

      You have to download the latest dev databases in order to construct database in the MySQL and PostgreSQL. If you use the SQLite version only, you can use the original dev databases.

  • data: Each text-to-SQL pairs with the oracle knowledge evidence is stored as a json file, i.e., mini_dev_sqlite.json is stored on ./mini_dev_data/mini_dev_sqlite.json. In each json file, it has three main parts:
    • db_id: the names of databases
    • question: the questions curated by human crowdsourcing according to database descriptions, database contents.
    • evidence: the external knowledge evidence annotated by experts for assistance of models or SQL annotators.
    • SQL: SQLs annotated by crowdsource referring to database descriptions, database contents, to answer the questions accurately.
  • ground-truth SQL file: The SQL file should be stored at ./llm/mini_dev_data/mini_dev_sqlite_gold.sql.
  • llm: It contains source codes to convert texts to SQLs by calling APIs from LLMs, such as GPT35-turbo-instruct, gpt-35-turbo, gpt-4, gpt-4-32k, and gpt-4-turbo.

Mini-Dev Dataset in MySQL and PostgreSQL

You can locate the SQL queries within the mini_dev_mysql.json and mini_dev_postgresql.json files. These queries have been transpiled from the original SQLite versions using the sqlglot package, then refined manually and with GPT-4 Turbo. After downloading the Mini-Dev dataset, each database folder will contain .sql and command.script files. Follow the instructions below to set up the database in MySQL and PostgreSQL:

MySQL

  1. Download and install the MySQL from the official website: https://dev.mysql.com/downloads/mysql/
  2. Set the environment variables:
export PATH=$PATH:/usr/local/mysql/bin
  1. Start the MySQL server:
sudo /usr/local/mysql/support-files/mysql.server start
  1. Login to the MySQL server and create the database (password will be the one you set during the installation)
mysql -u root -p
CREATE DATABASE BIRD;
  1. Construct the database by run the following command (You can find MySQL version database: BIRD_dev.sql in the MINIDEV_mysql folder):
mysql -u root -p BIRD < BIRD_dev.sql
  1. Examples that how to run mysql query in the Python (with pymysql) can be find in the examples/mysql_example.ipynb file.

  2. If you encounter the error: "this is incompatible with sql_mode=only_full_group_by", you can run the following command to disable the sql_mode:

select @@global.sql_mode;
SET GLOBAL sql_mode='{EVERYTHING SHOW IN THE ABOVE COMMAND EXCEPT ONLY_FULL_GROUP_BY}';

PostgreSQL

  1. Download and install the postgresql from the official website: https://www.postgresql.org/download/
  2. Download the pgAdmin4 from the official website: https://www.pgadmin.org/download/ (Recommended to monitor the database)
  3. In pgADmin4/terminal create a new database called BIRD
  4. Construct the database by run the following command (You can find PostgreSQL version database:BIRD_dev.sql in the MINIDEV_postgresql folder):
psql -U USERNAME -d BIRD -f BIRD_dev.sql
  1. Examples that how to run postgresql query in the Python (with Psycopg) can be find in the examples/postgresql_example.ipynb file.

Baseline performance on Mini-Dev Dataset

EX Evaluation

SQLite MySQL PostgreSQL
mixtral-8x7b 21.60 13.60 12.40
llama3-8b-instruct 24.40 24.60 18.40
phi-3-medium-128k-instruct 30.60 25.00 21.60
gpt-35-turbo-instruct 33.60 31.20 26.60
gpt-35-turbo 38.00 36.00 27.40
llama3-70b-instruct 40.80 37.00 29.40
TA + gpt-35-turbo 41.60 - -
TA + llama3-70b-instruct 42.80 - -
gpt-4-turbo 45.80 41.00 36.00
gpt-4-32k 47.00 43.20 35.00
gpt-4 47.80 40.80 35.80
TA + gpt-4-turbo 58.00 - -
TA + gpt-4o 63.00 - -

R-VES Evaluation

SQLite MySQL PostgreSQL
mixtral-8x7b 20.41 12.99 14.16
llama3-8b-instruct 23.27 23.66 17.90
phi-3-medium-128k-instruct 29.54 24.12 21.07
gpt-35-turbo-instruct 32.28 30.39 26.14
gpt-35-turbo 37.33 34.94 26.80
llama3-70b-instruct 39.02 35.82 28.80
TA + gpt-35-turbo 40.59 - -
TA + llama3-70b-instruct 41.37 - -
gpt-4-turbo 44.79 39.37 35.23
gpt-4-32k 45.29 42.79 34.59
gpt-4 45.91 39.92 35.24
TA + gpt-4-turbo 56.44 - -
TA + gpt-4o 60.86 - -

Soft F1-Score Evaluation

SQLite MySQL PostgreSQL
mixtral-8x7b 22.95 13.79 14.70
llama3-8b-instruct 27.87 27.49 19.35
phi-3-medium-128k-instruct 35.33 28.73 24.11
gpt-35-turbo-instruct 36.34 33.85 28.30
gpt-35-turbo 41.84 40.75 30.22
TA + gpt-35-turbo 44.25 - -
llama3-70b-instruct 44.38 40.95 31.43
TA + llama3-70b-instruct 46.66 - -
gpt-4-turbo 50.08 45.96 38.36
gpt-4-32k 51.92 47.38 39.55
gpt-4 52.69 45.78 38.96
TA + gpt-4-turbo 62.40 - -
TA + gpt-4o 66.97 - -

Citation

Please cite the repo if you think our work is helpful to you.

@article{li2024can,
  title={Can llm already serve as a database interface? a big bench for large-scale database grounded text-to-sqls},
  author={Li, Jinyang and Hui, Binyuan and Qu, Ge and Yang, Jiaxi and Li, Binhua and Li, Bowen and Wang, Bailin and Qin, Bowen and Geng, Ruiying and Huo, Nan and others},
  journal={Advances in Neural Information Processing Systems},
  volume={36},
  year={2024}
}
Downloads last month
171