Chinastark/bird_dataset huggingface dataset:
Database: simpson_episodes
Note: in November 2008 refers to air_date LIKE '2008-11%';
Question: List the stars of episodes aired in November 2008.
SQL: SELECT vote.stars FROM episode INNER JOIN vote ON vote.episode_id = episode.episode_id WHERE substr(episode.air_date, 1, 7) = '2008-11';
Database: simpson_episodes
Note: 5 stars refers to stars = 5; nominated refers to result = 'Nominee'; Prism award refers to award_category = 'Prism award'; on April 19 2009 refers to air_date = '2009-04-19';
Question: What is the title of episode with 5 stars and nominated for Prism Award which is aired on April 19, 2009?
SQL: SELECT episode.title FROM award INNER JOIN vote ON award.episode_id = vote.episode_id INNER JOIN episode ON award.episode_id = episode.episode_id WHERE episode.air_date = '2009-04-19' AND award.award_category = 'Prism Award' AND vote.stars = 5 AND award.result = 'Nominee';
Database: simpson_episodes
Note: highest votes refers to max(votes); nominated refers to result = 'Nominee';
Question: In episode with the highest votes, list the category of awards it is nominated for.
SQL: SELECT award.award_category FROM award INNER JOIN episode ON award.episode_id = episode.episode_id WHERE award.result = 'Nominee' ORDER BY episode.votes DESC LIMIT 1;
Database: simpson_episodes
Note: in 2009 refers to air_date LIKE '2009%'; credited refers to credited = 'true'; Sam Im refers to person = 'Sam Im'; for additional timer refers to role = 'additional timer';
Question: In episodes aired in 2009, how many of them are credited to Sam Im for additional timer?
SQL: SELECT count(*) FROM episode INNER JOIN credit ON episode.episode_id = credit.episode_id WHERE credit.credited = 'true' AND credit.person = 'Sam Im' AND substr(episode.air_date, 1, 4) = '2009' AND credit.role = 'additional timer';
Database: simpson_episodes
Note: stars greater than the 70% of average stars refers to stars > multiply(avg(stars), 0.7);
Question: List the title of the episode with stars greater than the 70% of average stars of all episodes.
SQL: SELECT DISTINCT episode.title FROM episode INNER JOIN vote ON vote.episode_id = episode.episode_id WHERE vote.stars > 0.7 * ( SELECT avg(stars) FROM vote );
Database: simpson_episodes
Note: being nominated refers to result = 'Nominee'; percentage = divide(count(result = 'Nominee'), count(result)) * 100%;
Question: In year 2009, what is the percentage of the episode titled by "Gone Maggie Gone" being nominated?
SQL: SELECT cast((sum(CASE WHEN award.result = 'Nominee' THEN 1 ELSE 0 END) - sum(CASE WHEN award.result = 'Winner' THEN 1 ELSE 0 END)) AS REAL) * 100 / count(award.result) FROM award INNER JOIN episode ON award.episode_id = episode.episode_id WHERE episode.title = 'Gone Maggie Gone' AND award.year = 2009;
Database: student_loan
Note: have never been absent refers to `month` = 0;
Question: How many students have never been absent from school?
SQL: SELECT count(name) FROM longest_absense_from_school WHERE `month` = 0
Database: student_loan
Note: absent from school for the longest time refers to MAX(month);
Question: For the students who have been absent from school for the longest time, how many months have they been absent?
SQL: SELECT max(MONTH) FROM longest_absense_from_school
Database: student_loan
Note: belong to the navy department refers to organ = 'navy';
Question: How many students belong to the navy department?
SQL: SELECT count(name) FROM enlist WHERE organ = 'navy'
Database: student_loan
Note: absent from school for more than 5 months refers to `month`  >= 5;
Question: Among the students that have been absent from school for more than 5 months, how many of them are male?
SQL: SELECT count(longest_absense_from_school.name) FROM longest_absense_from_school INNER JOIN male ON longest_absense_from_school.`name` = male.`name` WHERE longest_absense_from_school.`month` >= 5
Database: student_loan
Note: belong to the navy department refers to organ = 'navy';
Question: Please list the names of the male students that belong to the navy department.
SQL: SELECT enlist.name FROM enlist INNER JOIN male ON enlist.`name` = male.`name` WHERE enlist.organ = 'navy'
Database: student_loan
Note: absent from school for over 5 months refers to `month` > 5;
Question: Among the students that have filed for bankruptcy, how many of them have been absent from school for over 5 months?
SQL: SELECT count(filed_for_bankrupcy.name) FROM filed_for_bankrupcy INNER JOIN longest_absense_from_school ON filed_for_bankrupcy.`name` = longest_absense_from_school.`name` WHERE longest_absense_from_school.`month` > 5
Database: student_loan
Note: from the navy department refers to organ = 'navy'; have payment due refers to bool = 'pos';
Question: Among the students from the navy department, how many of them have payment due?
SQL: SELECT count(enlist.name) FROM enlist INNER JOIN no_payment_due ON enlist.`name` = no_payment_due.`name` WHERE enlist.organ = 'navy' AND no_payment_due.bool = 'pos'
Database: student_loan
Note: male students that are disabled and have filed for bankruptcy refers to name that appeared in all three male, disabled and filed_for_bankrupcy tables.;
Question: Please list the male students that are disabled and have filed for bankruptcy.
SQL: SELECT disabled.name, male.name, filed_for_bankrupcy.name FROM disabled INNER JOIN male ON disabled.`name` = male.`name` INNER JOIN filed_for_bankrupcy ON disabled.`name` = filed_for_bankrupcy.`name`
Database: student_loan
Note: females students are disabled refers to name that appeared in both disabled and male tables;
Question: How many female students are disabled?
SQL: SELECT count(name) FROM disabled WHERE name NOT IN ( SELECT name FROM male )
Database: student_loan
Note: are unemployed and have payment due refers to;
Question: How many students are unemployed and have payment due?
SQL: SELECT count(unemployed.name) FROM unemployed INNER JOIN no_payment_due ON unemployed.`name` = no_payment_due.`name`
Database: student_loan
Note: navy department refers to organ = 'navy'; longest time to be absent from school refers to MAX(month);
Question: What is the longest time for a student from the navy department to be absent from school?
SQL: SELECT longest_absense_from_school.month FROM longest_absense_from_school INNER JOIN enlist ON longest_absense_from_school.`name` = enlist.`name` WHERE enlist.organ = 'navy' ORDER BY longest_absense_from_school.`month` DESC LIMIT 1
Database: student_loan
Note: never been absent from school refers to month = 0;
Question: How many disabled students have never been absent from school?
SQL: SELECT count(longest_absense_from_school.name) FROM longest_absense_from_school INNER JOIN disabled ON longest_absense_from_school.`name` = disabled.`name` WHERE longest_absense_from_school.`month` = 0
Database: student_loan
Note: absent from school for 9 months refers to month = 9;
Question: Please list the departments the students are absent from school for 9 months are in.
SQL: SELECT enlist.organ FROM longest_absense_from_school INNER JOIN enlist ON longest_absense_from_school.`name` = enlist.`name` WHERE longest_absense_from_school.`month` = 9
Database: student_loan
Note: department refers to organ; most disabled students refers to MAX(disabled.name);
Question: Which department has the most disabled students?
SQL: SELECT enlist.organ, count(disabled.name) FROM disabled INNER JOIN enlist ON disabled.`name` = enlist.`name` GROUP BY enlist.organ ORDER BY count(disabled.name) DESC LIMIT 1
Database: student_loan
Note: females students have filed for bankruptcy refers to name that appeared in both filed_for_bankrupcy and male tables;
Question: Please list all the female students that have filed for bankruptcy.
SQL: SELECT name FROM filed_for_bankrupcy WHERE name NOT IN ( SELECT name FROM male )
Database: student_loan
Note: in the navy department refers to organ = 'navy'; percentage refers to DIVIDE(COUNT(name where organ = 'navy'), COUNT(name));
Question: What is the percentage of male students in the navy department?
SQL: SELECT cast(count(male.name) AS REAL) * 100 / count(enlist.name) FROM enlist LEFT JOIN male ON enlist.`name` = male.`name` WHERE enlist.organ = 'navy'
Database: student_loan
Note: average time refers to DIVIDE(SUM(`month`), COUNT(name));
Question: What is the average time for a disabled student to be absent from school?
SQL: SELECT avg(longest_absense_from_school.month) FROM longest_absense_from_school INNER JOIN disabled ON longest_absense_from_school.`name` = disabled.`name`
Database: student_loan
Note: in the foreign legion organ = 'foreign_legion';
Question: Name all students enlisted in the foreign legion.
SQL: SELECT name FROM enlist WHERE organ = 'foreign_legion'
Database: student_loan
Note: payment due refers to bool = 'pos' means the student has payment due , bool = 'neg' means the student does not have payment due;
Question: Does student348 have a due payment?
SQL: SELECT bool FROM no_payment_due WHERE name = 'student348'
Database: student_loan
Question: Which school is student829 enrolled in?
SQL: SELECT school FROM enrolled WHERE name = 'student829'
Database: student_loan
Question: How many months has student217 been absent?
SQL: SELECT MONTH FROM longest_absense_from_school WHERE name = 'student217'
Database: student_loan
Note: absent for 6 months `month` = 6;
Question: List all students that have been absent for 6 months.
SQL: SELECT name FROM longest_absense_from_school WHERE `month` = 6
Database: student_loan
Question: Which organization did student285 enlist?
SQL: SELECT organ FROM enlist WHERE name = 'student285'
Database: student_loan
Question: Is student281 disabled and which school is the student enrolled in?
SQL: SELECT disabled.name, enrolled.school FROM enrolled INNER JOIN disabled ON enrolled.`name` = disabled.`name` WHERE enrolled.name = 'studendisabled81'
Database: student_loan
Note: in the air force refers to organ = 'air_force';
Question: List all students in the air force and which school they were enrolled at.
SQL: SELECT enrolled.name, enrolled.school FROM enrolled INNER JOIN enlist ON enrolled.`name` = enlist.`name` WHERE enlist.organ = 'air_force'
Database: student_loan
Note: no due payments refers to bool = 'neg'; not males refers to not in male table;
Question: List 10 students that have no due payments and are not males.
SQL: SELECT no_payment_due.name FROM no_payment_due INNER JOIN person ON no_payment_due.`name` = person.`name` WHERE person.`name` NOT IN ( SELECT name FROM male ) AND no_payment_due.bool = 'neg'
Database: student_loan
Note: with due payments refers to bool = 'pos'; organization refers to organ;
Question: Name 5 students with due payments that are enlisted alongside which organization they were enlisted.
SQL: SELECT enlist.organ, no_payment_due.name FROM no_payment_due INNER JOIN enlist ON no_payment_due.`name` = enlist.`name` WHERE no_payment_due.bool = 'pos' LIMIT 5
Database: student_loan
Note: enrolled in SMC refers to school = 'smc';
Question: Name all disabled students that are enrolled in SMC.
SQL: SELECT disabled.name FROM enrolled INNER JOIN disabled ON enrolled.`name` = disabled.`name` WHERE enrolled.school = 'smc'
Database: student_loan
Note: in the foreign legion refers to organ = 'foreign_legion';
Question: Which students that filed for bankruptcy are also in the foreign legion?
SQL: SELECT filed_for_bankrupcy.name FROM enlist INNER JOIN filed_for_bankrupcy ON enlist.`name` = filed_for_bankrupcy.`name` WHERE enlist.organ = 'foreign_legion'
Database: student_loan
Note: have no due payments refers to bool = 'neg';
Question: How many male students have no due payments?
SQL: SELECT count(no_payment_due.name) FROM no_payment_due INNER JOIN male ON no_payment_due.name = male.name WHERE no_payment_due.bool = 'neg'
Database: student_loan
Note: in the marines refers to organ = 'marines'; absent for 6 months refers to month = 6;
Question: Which students that are in the marines have been absent for 6 months?
SQL: SELECT longest_absense_from_school.name FROM longest_absense_from_school INNER JOIN enlist ON longest_absense_from_school.`name` = enlist.`name` WHERE enlist.organ = 'marines' AND longest_absense_from_school.`month` = 6
Database: student_loan
Note: from SMC refers to school = 'smc';
Question: How many students from SMC are unemployed?
SQL: SELECT unemployed.name FROM enrolled INNER JOIN unemployed ON enrolled.`name` = unemployed.`name` WHERE enrolled.school = 'smc'
Database: student_loan
Note: absent for 6 months refers to month = 6;
Question: How many unemployed students are there that have been absent for 6 months?
SQL: SELECT longest_absense_from_school.name FROM longest_absense_from_school INNER JOIN unemployed ON longest_absense_from_school.`name` = unemployed.name WHERE longest_absense_from_school.`month` = 6
Database: student_loan
Note: in the peace corps refers to organ = 'peace_corps'; from UCSD refers to school = 'ucsd';
Question: Count the number of students from UCSD enlisted in the peace corps.
SQL: SELECT count(enlist.name) FROM enlist INNER JOIN enrolled ON enlist.`name` = enrolled.`name` WHERE enrolled.school = 'ucsd' AND enlist.organ = 'peace_corps'
Database: student_loan
Note: organization refers to organ;
Question: Student21 is enlisted in which organization and has the student been absent?
SQL: SELECT longest_absense_from_school.month, enlist.organ FROM enlist INNER JOIN longest_absense_from_school ON enlist.`name` = longest_absense_from_school.`name` WHERE enlist.name = 'studenlongest_absense_from_school1'
Database: student_loan
Note: have a due payment refers to bool = 'pos'; in foreign legions refers to organ = 'foreign_legion'; ratio refers to DIVIDE(COUNT(bool = 'pos'), COUNT(bool = 'neg'));
Question: What is the percentage ratio of students who are enlisted in foreign legions that have a due payment?
SQL: SELECT cast(sum(iif(no_payment_due.bool = 'pos', 1, 0)) AS REAL) * 100 / sum(iif(no_payment_due.bool = 'neg', 1, 0)) FROM no_payment_due INNER JOIN enlist ON no_payment_due.`name` = enlist.`name` WHERE enlist.organ = 'foreign_legion'
Database: student_loan
Note: in the navy refers to organ = 'navy'; enrolled in OCC refers to school = 'occ';
Question: What percentage of students who enlisted in the navy make up the number of students enrolled in OCC?
SQL: SELECT cast(sum(iif(enrolled.school = 'occ', 1.0, 0)) AS REAL) * 100 / count(enrolled.name) FROM enrolled INNER JOIN enlist ON enrolled.`name` = enlist.`name` WHERE enlist.organ = 'navy'
Database: student_loan
Note: longest absence duration refers to MAX(month);
Question: List out student IDs that have the longest absence duration from school.
SQL: SELECT name FROM longest_absense_from_school WHERE `month` = ( SELECT max(MONTH) FROM longest_absense_from_school )
Database: student_loan
Question: What is the total number of students in the school?
SQL: SELECT count(name) FROM person
Database: student_loan
Note: longest students absence duration MAX(month);
Question: What is the longest students absence duration from school?
SQL: SELECT name, MONTH FROM longest_absense_from_school WHERE `month` = ( SELECT max(MONTH) FROM longest_absense_from_school )
Database: student_loan
Note: absence for 4 month refers to month = 4;
Question: How many students were absence for 4 month?
SQL: SELECT count(name) FROM longest_absense_from_school WHERE MONTH = 4
Database: student_loan
Question: What is the number of unemployed and bankrupt students?
SQL: SELECT count(unemployed.name) FROM unemployed INNER JOIN filed_for_bankrupcy ON unemployed.name = filed_for_bankrupcy.name
Database: student_loan
Note: organization refers to organ;
Question: Does disable students join organization. If yes, please indicate the organization joined by the students.
SQL: SELECT DISTINCT enlist.organ FROM disabled INNER JOIN enlist ON disabled.`name` = enlist.`name`
Database: student_loan
Note: have payment dues refers to bool = 'pos';
Question: How many unemployed and bankrupt students that have payment dues?
SQL: SELECT count(unemployed.name) FROM unemployed INNER JOIN filed_for_bankrupcy ON unemployed.name = filed_for_bankrupcy.name INNER JOIN no_payment_due ON filed_for_bankrupcy.name = no_payment_due.name WHERE no_payment_due.bool = 'pos'
Database: student_loan
Note: if student name appear in disabled then student is disabled and vice versa; if student name appear in male then student is male and vice versa;
Question: Please check if student 124 is disabled male.
SQL: SELECT iif(disabled.name IS NULL, 'female', 'male') FROM male LEFT JOIN disabled ON male.name = disabled.name WHERE male.name = 'studenmale24'
Database: student_loan
Note: school debt status refers to bool; bool = 'pos' means has payment due; bool = 'neg' means doesn't has payment due; student appear in male.name means he is a male; student does not appear in male.name means she is a female;
Question: What is the employment, disability, gender and school debt status for student180 and student117?
SQL: SELECT ( SELECT count(name) FROM disabled WHERE name IN ('student180', 'student117') ), ( SELECT count(name) FROM unemployed WHERE name IN ('student180', 'student117') ), ( SELECT count(name) FROM male WHERE name IN ('student180', 'student117') ), ( SELECT count(name) FROM no_payment_due WHERE name IN ('student180', 'student117'))
Database: student_loan
Note: joined a marines refers to organ = 'marines'; air force organization refers to organ = 'air_force';
Question: How many female students joined a marines and air force organization?
SQL: SELECT count(name) FROM enlist WHERE organ IN ('marines', 'air_force') AND name NOT IN ( SELECT name FROM male )
Database: student_loan
Note: organization joined refers to organ;
Question: List out the organization joined and school enrolled by student27, student17 and student101?
SQL: SELECT enrolled.school, enlist.organ FROM enrolled INNER JOIN enlist ON enrolled.`name` = enlist.`name` WHERE enrolled.`name` IN ('studenenlist7,studenenrolled7,studetn101')
Database: student_loan
Note: ratio refers to DIVIDE(COUNT(name not from male), COUNT(name from male));
Question: What is the ratio of disable female to male students?
SQL: SELECT cast(sum(iif(male.name IS NULL, 1, 0)) AS REAL) * 100 / count(male.name) FROM disabled LEFT JOIN male ON disabled.`name` = male.`name`
Database: student_loan
Note: female students refers to enlist.name who are NOT in male.name;
Question: How many female students are not joining any of the organization?
SQL: SELECT count(name) FROM person WHERE name NOT IN ( SELECT name FROM male ) AND name NOT IN ( SELECT name FROM enrolled )
Database: student_loan
Note: make payment before due refers to bool = 'neg';
Question: List out all bankrupt students that are able to make payment before due?
SQL: SELECT filed_for_bankrupcy.name FROM filed_for_bankrupcy INNER JOIN no_payment_due ON filed_for_bankrupcy.name = no_payment_due.name WHERE no_payment_due.bool = 'neg'
Database: student_loan
Note: average refers to DIVIDE(SUM(month), COUNT(name));
Question: What is the average absence period of a student?
SQL: SELECT avg(MONTH) FROM longest_absense_from_school
Database: student_loan
Note: average refers to DIVIDE(SUM(month), COUNT(name));
Question: What is the average of absence for an employed students?
SQL: SELECT avg(MONTH) FROM longest_absense_from_school WHERE name NOT IN ( SELECT name FROM unemployed )
Database: student_loan
Note: average refers to DIVIDE(SUM(month), COUNT(name));
Question: What is the average absence period of a disabled student?
SQL: SELECT avg(longest_absense_from_school.month) FROM longest_absense_from_school INNER JOIN disabled ON longest_absense_from_school.name = disabled.name
Database: student_loan
Note: organization refers to organ;
Question: Which organization does student 313 belong to?
SQL: SELECT organ FROM enlist WHERE name = 'studenT113'
Database: student_loan
Note: enlisted in the fire-department refers to organ = 'fire_department';
Question: How many students enlisted in the fire-department?
SQL: SELECT count(name) FROM enlist WHERE organ = 'fire_department'
Database: student_loan
Note: have never been absent refers to `month` = 0;
Question: How many students who have never been absent from school?
SQL: SELECT count(name) FROM longest_absense_from_school WHERE MONTH = 0
Database: student_loan
Note: absent above 2 months refers to month > 2;
Question: How many students have been absent above 2 months?
SQL: SELECT count(name) FROM longest_absense_from_school WHERE MONTH > 2
Database: student_loan
Note: do not have payment due refers to bool = 'neg';
Question: State the number of students do not have payment due.
SQL: SELECT count(name) FROM no_payment_due WHERE bool = 'neg'
Database: student_loan
Note: who have payment due refers to bool = 'pos';
Question: Give the number of students who have payment due.
SQL: SELECT count(name) FROM no_payment_due WHERE bool = 'pos'
Database: student_loan
Note: never been absent from school refers to month = 0;
Question: Mention the name of disabled students who have never been absent from school.
SQL: SELECT disabled.name FROM disabled INNER JOIN longest_absense_from_school ON disabled.name = longest_absense_from_school.name WHERE longest_absense_from_school.month = 0
Database: student_loan
Note: enlisted in the navy organization refers to organ = 'navy';
Question: How many unemployed students are enlisted in the navy organization?
SQL: SELECT count(unemployed.name) FROM unemployed INNER JOIN enlist ON unemployed.name = enlist.name WHERE enlist.organ = 'navy'
Database: student_loan
Note: belong to foreign legion refers to organ = 'foreign_legion';
Question: Count the number of male students who belong to foreign legion.
SQL: SELECT count(male.name) FROM male INNER JOIN enlist ON male.name = enlist.name WHERE enlist.organ = 'foreign_legion'
Database: student_loan
Note: enlisted in the air force refers to organ = 'air_force';
Question: List out the number of female students who enlisted in the air force.
SQL: SELECT count(name) FROM enlist WHERE organ = 'air_force' AND name NOT IN ( SELECT name FROM male )
Database: student_loan
Note: longest duration of absense refers to MAX(month);
Question: State name of disabled students who have the longest duration of absense from school.
SQL: SELECT disabled.name FROM disabled INNER JOIN longest_absense_from_school ON disabled.name = longest_absense_from_school.name ORDER BY longest_absense_from_school.month DESC LIMIT 1
Database: student_loan
Note: enlisted in marines refers to organ = 'marines';
Question: State the unemployed students who enlisted in marines.
SQL: SELECT unemployed.name FROM unemployed INNER JOIN enlist ON unemployed.name = enlist.name WHERE enlist.organ = 'marines'
Database: student_loan
Note: average refers to DIVIDE(SUM(month), COUNT(name));
Question: Calculate the average duration of absense of disabled students.
SQL: SELECT avg(longest_absense_from_school.month) FROM longest_absense_from_school INNER JOIN disabled ON longest_absense_from_school.name = disabled.name
Database: student_loan
Note: percentage refers to DIVIDE(COUNT(month > 5), COUNT(month));
Question: What is the percentage of unemployed students who have been absent for 5 months from school?
SQL: SELECT cast(sum(iif(longest_absense_from_school.month > 5, 1, 0)) AS REAL) * 100 / count(longest_absense_from_school.month) FROM longest_absense_from_school INNER JOIN unemployed ON longest_absense_from_school.name = unemployed.name
Database: student_loan
Note: absent for 8 months refers to month = 8;
Question: How many unemployed disabled students have been absent for 8 months from school?
SQL: SELECT count(longest_absense_from_school.name) FROM longest_absense_from_school INNER JOIN unemployed ON longest_absense_from_school.name = unemployed.name INNER JOIN disabled ON unemployed.name = disabled.name WHERE longest_absense_from_school.month = 8
Database: student_loan
Note: longest duration of absense refers to MAX(month);
Question: State name of unemployed students who have the longest duration of absense from school.
SQL: SELECT longest_absense_from_school.name FROM longest_absense_from_school INNER JOIN unemployed ON longest_absense_from_school.name = unemployed.name ORDER BY longest_absense_from_school.month DESC LIMIT 1