Chinastark/bird_dataset huggingface dataset:
Database: student_loan
Note: have never been absent from school refers to month = 0;
Question: Mention the name of unemployed students who have never been absent 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 WHERE longest_absense_from_school.month = 0
Database: student_loan
Note: have been absent for 3 months from school refers to month = 3;
Question: How many disabled students have been absent for 3 months 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 = 3
Database: student_loan
Note: have never been absent refers to month = 0;
Question: Mention the name of students who filed for bankruptcy and have never been absent from school.
SQL: SELECT longest_absense_from_school.name FROM longest_absense_from_school INNER JOIN filed_for_bankrupcy ON longest_absense_from_school.name = filed_for_bankrupcy.name WHERE longest_absense_from_school.month = 0
Database: student_loan
Note: longest duration of absense refers to MAX(month);
Question: State name of students who filed for bankruptcy and have the longest duration of absense from school.
SQL: SELECT longest_absense_from_school.name FROM longest_absense_from_school INNER JOIN filed_for_bankrupcy ON longest_absense_from_school.name = filed_for_bankrupcy.name ORDER BY longest_absense_from_school.month DESC LIMIT 1
Database: student_loan
Note: student name appear in male table means student is a male, student does not appear in male table means student is a female;
Question: What is the gender of student1000?
SQL: SELECT iif(t.result = 0, 'female', 'male') AS re FROM ( SELECT count(name) AS RESULT FROM male WHERE name = 'studenT1000' ) t
Database: student_loan
Question: How many students are disabled?
SQL: SELECT count(name) FROM disabled
Database: student_loan
Note: absents for more than 6 months refers to month > 6;
Question: How many students have been absents for more than 6 months?
SQL: SELECT count(name) FROM longest_absense_from_school WHERE MONTH > 6
Database: student_loan
Note: absents the most refers to MAX(month);
Question: Which students have absents the most?
SQL: SELECT name FROM longest_absense_from_school WHERE MONTH = ( SELECT max(MONTH) FROM longest_absense_from_school )
Database: student_loan
Note: enlisted in the army refers to organ = 'army';
Question: How many students are enlisted in the army?
SQL: SELECT count(name) FROM enlist WHERE organ = 'army'
Database: student_loan
Note: average refers to DIVIDE(SUM(month), COUNT(name));
Question: Find the average number of absences for each student.
SQL: SELECT avg(MONTH) FROM longest_absense_from_school
Database: student_loan
Note: enlisted in foreign legion refers to organ = 'foreign_legion'; peace corps refers to organ = 'peace_corps'; army refers to organ = 'army';
Question: Sum up the number of students enlisted in foreign legion, peace corps and army.
SQL: SELECT count(name) FROM enlist WHERE organ IN ('army', 'peace_corps', 'foreign_legion')
Database: student_loan
Note: enlisted in marines refers to organ = 'marines';
Question: Among the students enlisted in marines, how many of them are disabled?
SQL: SELECT count(enlist.name) FROM enlist INNER JOIN disabled ON enlist.name = disabled.name WHERE enlist.organ = 'marines'
Database: student_loan
Note: still have payment due refers to bool = 'pos';
Question: How many unemployed students still have payment due?
SQL: SELECT count(unemployed.name) FROM unemployed INNER JOIN no_payment_due ON unemployed.name = no_payment_due.name WHERE no_payment_due.bool = 'pos'
Database: student_loan
Note: had never been absent refers to month = 0;
Question: Which female students had never been absent?
SQL: SELECT longest_absense_from_school.name FROM male INNER JOIN longest_absense_from_school ON male.name <> longest_absense_from_school.name WHERE longest_absense_from_school.month = 0
Database: student_loan
Note: highest number of disabled students refers to MAX(COUNT(disabled.name));
Question: Which school has the highest number of disabled students?
SQL: SELECT t.school FROM ( SELECT enrolled.school, count(enrolled.name) AS num FROM disabled INNER JOIN enrolled ON disabled.name = enrolled.name GROUP BY enrolled.school ) t ORDER BY t.num DESC LIMIT 1
Database: student_loan
Note: organization refers to organ; students who filed for bankrupcy refers to file_for_bankrupcy.name;
Question: List all the organisations of students who filed for bankcrupcy.
SQL: SELECT enlist.organ FROM filed_for_bankrupcy INNER JOIN enlist ON filed_for_bankrupcy.name = enlist.name
Database: student_loan
Note: more than one organization refers to COUNT(organ) > 1;
Question: How many male students join more than one organization?
SQL: SELECT count(t.a) FROM ( SELECT count(DISTINCT male.name) AS a, count(enlist.organ) AS num FROM male INNER JOIN enlist ON male.name = enlist.name GROUP BY male.name ) t WHERE t.num > 1
Database: student_loan
Note: navy students refers to organ = 'navy'; disabled student refers to disabled.name;
Question: List all the navy students who are disabled.
SQL: SELECT disabled.name FROM disabled INNER JOIN enlist ON disabled.name = enlist.name WHERE enlist.organ = 'navy'
Database: student_loan
Note: SMC's students refers to school = 'smc'; absent for 7 months refers to month = 7;
Question: How many SMC's students that absent for 7 months?
SQL: SELECT count(enrolled.name) FROM enrolled INNER JOIN longest_absense_from_school ON enrolled.name = longest_absense_from_school.name WHERE enrolled.school = 'smc' AND longest_absense_from_school.month = 7
Database: student_loan
Question: List all the disabled female students.
SQL: SELECT disabled.name FROM disabled INNER JOIN male ON disabled.name <> male.name
Database: student_loan
Note: ratio refers to DIVIDE(COUNT(name from unemployed), COUNT(name from disabled));
Question: Calculate the ratio between unemployed students and disabled students.
SQL: SELECT cast(( SELECT count(name) FROM unemployed ) AS REAL ) / ( SELECT count(name) FROM disabled )
Database: student_loan
Note: percentage refers to DIVIDE(COUNT(organ = 'fire_department'), COUNT(name));
Question: Find the percentage of male students enlisted in the fire 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 = 'fire_department'
Database: student_loan
Note: absense from school for 5 month refers to month = 5;
Question: How many students has the longest absense from school for 5 months?
SQL: SELECT count(name) FROM longest_absense_from_school WHERE MONTH = 5
Database: student_loan
Note: enlisted in the army refers to organ = 'army';
Question: How many students are enlisted in the Army organization?
SQL: SELECT count(name) FROM enlist WHERE organ = 'army'
Database: student_loan
Note: enrolled in UCLA refers to school = 'ucla';
Question: How many students are enrolled in UCLA school?
SQL: SELECT count(name) FROM enrolled WHERE school = 'ucla'
Database: student_loan
Note: longest absense refers to MAX(month);
Question: List at least 5 students who has the longest absense from schoool?
SQL: SELECT name FROM longest_absense_from_school ORDER BY MONTH DESC LIMIT 5
Database: student_loan
Note: joined two organization refers to COUNT(organ) >= 2;
Question: How many of the students joined two organization?
SQL: SELECT count(name) FROM enlist WHERE organ >= 2
Database: student_loan
Note: enlisted in the navy organization refers to organ = 'navy';
Question: How many students are enlisted in the Navy organization?
SQL: SELECT count(name) FROM enlist WHERE organ = 'navy'
Database: student_loan
Note: do not have payment due refers to bool = 'neg';
Question: How many male stuents do not have payment due?
SQL: SELECT count(male.name) FROM male INNER JOIN no_payment_due ON male.name = no_payment_due.name WHERE no_payment_due.bool = 'neg'
Database: student_loan
Note: enlisted in the Peace Corps refers to organ = 'peace_corps'; enrolled in UCSD school refers to school = 'ucsd';
Question: How many students are enlisted in the Peace Corps organization are enrolled in UCSD school?
SQL: SELECT count(enlist.name) FROM enlist INNER JOIN enrolled ON enlist.name = enrolled.name WHERE enlist.organ = 'peace_corps' AND enrolled.school = 'ucsd'
Database: student_loan
Note: have no payment due refers to bool = 'neg';
Question: Among the unemployed students, how many of them have no payment due?
SQL: SELECT count(unemployed.name) FROM unemployed INNER JOIN no_payment_due ON unemployed.name = no_payment_due.name WHERE no_payment_due.bool = 'neg'
Database: student_loan
Note: have no payment due refers to bool = 'neg'; female students refers to name NOT in male table;
Question: How many female students have no payment due?
SQL: SELECT count(name) FROM no_payment_due WHERE name NOT IN ( SELECT name FROM male )
Database: student_loan
Note: never been absent refers to month = 0;
Question: How many unemployed students have never been absent?
SQL: SELECT count(unemployed.name) FROM longest_absense_from_school INNER JOIN unemployed ON unemployed.name = longest_absense_from_school.name WHERE longest_absense_from_school.month = 0
Database: student_loan
Note: no payment due refers to bool = 'neg'; organization refers to organ; organ = 'fire_department';
Question: List at least 10 students who have no payment due and are enlisted in Fire Department organization.
SQL: SELECT no_payment_due.name FROM no_payment_due INNER JOIN enlist ON enlist.name = no_payment_due.name WHERE no_payment_due.bool = 'neg' AND enlist.organ = 'fire_department' LIMIT 10
Database: student_loan
Note: female students refers to enlist.name who are NOT in male.name; organization refers to organ; organ = 'navy';
Question: How many female students are enlisted in the Navy organization?
SQL: SELECT count(name) FROM enlist WHERE organ = 'navy' AND name NOT IN ( SELECT name FROM male )
Database: student_loan
Note: organization refers to organ; organ = 'army';
Question: How many unemployed students are enlisted in the Army organization?
SQL: SELECT count(enlist.name) FROM enlist INNER JOIN unemployed ON unemployed.name = enlist.name WHERE enlist.organ = 'army'
Database: student_loan
Note: have payment due refers to bool = 'pos';
Question: How many unemployed students have payment due?
SQL: SELECT count(no_payment_due.name) FROM no_payment_due INNER JOIN unemployed ON unemployed.name = no_payment_due.name WHERE no_payment_due.bool = 'pos'
Database: student_loan
Note: have payment due refers to bool = 'pos'; organization refers to organ; organ = 'Peace Corps';
Question: List at least 5 students who have payment due and are enlisted in Peace Corps organization?
SQL: SELECT no_payment_due.name FROM no_payment_due INNER JOIN enlist ON enlist.name = no_payment_due.name WHERE enlist.organ = 'peace_corps' AND no_payment_due.bool = 'pos' LIMIT 5
Database: student_loan
Note: female refers to disabled.name who are NOT in male.name;
Question: How many disabled students are female?
SQL: SELECT count(name) FROM disabled WHERE name NOT IN ( SELECT name FROM male )
Database: student_loan
Note: have payment due refers to bool = 'pos';
Question: How many disabled students have payment due?
SQL: SELECT count(disabled.name) FROM disabled INNER JOIN no_payment_due ON no_payment_due.name = disabled.name WHERE no_payment_due.bool = 'pos'
Database: student_loan
Note: average = DIVIDE(COUNT(disabled.name who are not in male.name WHERE organ = 'foreign_legion'), COUNT(disabled.name)); female students who are disabled refers to disabled.name who are NOT in male.name; organization refers to organ; organ = 'Foreign Legion';
Question: Calculate the average number of female students who are disabled and who joined Foreign Legion organization.
SQL: SELECT cast(sum(iif(male.name IS NULL, 1, 0)) AS REAL) / count(disabled.name) FROM disabled INNER JOIN enlist ON disabled.name = enlist.name LEFT JOIN male ON enlist.name = male.name WHERE enlist.organ = 'foreign_legion'
Database: student_loan
Note: ratio = CONCAT(MULTIPLY(DIVIDE(COUNT(enlist.name WHERE organ = 'fire_department' which is NOT in male.name), COUNT(enlist.name WHERE organ = 'fire_department),'%'))) AS FEmale; ratio = CONCAT(MULTIPLY(DIVIDE(COUNT(enlist.name WHERE organ = 'fire_department' which is IN male.name), COUNT(enlist.name WHERE organ = 'fire_department), 100))) AS male; female students refers to enlist.name who are NOT in male.name; male students refers to enlist.name who are IN male.name; organization refers to organ; organ = 'fire_department';
Question: Calculate the ratio in percentage between the average number of female and male students who joined Fire Department organization.
SQL: SELECT cast(sum(iif(male.name IS NULL, 1, 0)) AS REAL) * 100 / count(enlist.name), cast(sum(iif(male.name IS NOT NULL, 1, 0)) AS REAL) * 100 / count(enlist.name) FROM enlist LEFT JOIN male ON male.name = enlist.name WHERE enlist.organ = 'fire_department'
Database: student_loan
Note: navy refers to organ = 'navy';
Question: How many students enlisted in the navy?
SQL: SELECT count(name) FROM enlist WHERE organ = 'navy'
Database: student_loan
Note: percentage = CONCAT(DIVIDE(MULTIPLY(COUNT(name WHERE month = 0), 100), COUNT(name)),'%'); never been absent refers to month = 0;
Question: Calculate the percentage of students who have never been absent.
SQL: SELECT cast(sum(iif(MONTH = 0, 1, 0)) AS REAL) * 100 / count(name) FROM longest_absense_from_school
Database: student_loan
Note: ratio =  DIVIDE(COUNT(name WHERE `bool` = 'pos'), COUNT(name WHERE `bool` = 'neg')); have payment due refers to `bool` = 'pos'; no payment due refers to `bool` = 'neg';
Question: What is the ratio of students who have payment due and those who do not have payment due?
SQL: SELECT cast(sum(iif(`bool` = 'pos', 1, 0)) AS REAL) / sum(iif(`bool` = 'neg', 1, 0)) FROM no_payment_due
Database: student_loan
Note: enrolled for 15 months refers to month = 15;
Question: Provide the students' names and schools who enrolled for 15 months.
SQL: SELECT name, school FROM enrolled WHERE MONTH = 15
Database: student_loan
Note: average = DIVIDE(FLOOR(COUNT(name), COUNT(DISTINCT organ)));
Question: Calculate the average enlisted students per organization.
SQL: SELECT cast(count(name) AS REAL) * 100 / count(DISTINCT organ) FROM enlist
Database: student_loan
Note: enrolled schools refers to school; duration refers to month; student214 is a name of student;
Question: List down the enrolled schools and duration of student214.
SQL: SELECT school, MONTH FROM enrolled WHERE name = 'student214'
Database: student_loan
Note: percentage = CONCAT(DIVIDE(MULTIPLY(COUNT(disabled.name), 100), (COUNT(person.name that is not in disabled.name))),'%');
Question: Among all students, calculate the percentage of disabled students.
SQL: SELECT cast(count(disabled.name) AS REAL) * 100 / count(person.name) FROM person LEFT JOIN disabled ON disabled.name = person.name
Database: student_loan
Note: absent for 9 months refers to month = 9;
Question: Among students who have been absent for nine months, how many of them are disabled?
SQL: SELECT count(disabled.name) FROM disabled LEFT JOIN longest_absense_from_school ON longest_absense_from_school.name = disabled.name WHERE longest_absense_from_school.month = 9
Database: student_loan
Note: students name who did not file a bankruptcy refers to person.name who are NOT in filed_for_bankrupcy.name;
Question: List down the student names who did not file for bankruptcy.
SQL: SELECT name FROM person WHERE name NOT IN ( SELECT name FROM filed_for_bankrupcy )
Database: student_loan
Note: female students refers to enlist.name who are NOT in male.name; air force refers to organ = 'air_force';
Question: List any five female students' names who enlisted for the air force.
SQL: SELECT enlist.name FROM enlist LEFT JOIN male ON male.name = enlist.name WHERE male.name IS NULL AND enlist.organ = 'air_force' LIMIT 5
Database: student_loan
Note: students who are not disabled refers to person.name who are NOT in disabled.name;
Question: Calculate the number of students who are not disabled.
SQL: SELECT count(CASE  WHEN disabled.name IS NULL THEN person.name END) AS "number" FROM person LEFT JOIN disabled ON disabled.name = person.name
Database: student_loan
Note: male.name = 'student995' means student995's gender is male; if 'student995' can not be found in 'male.name', it means student995 is female;
Question: Define the gender of "student995" and his/her enrolled schools.
SQL: SELECT iif(male.name IS NULL, 'female', 'male') AS gen , enrolled.school FROM enrolled LEFT JOIN male ON male.name = enrolled.name WHERE enrolled.name = 'student995'
Database: student_loan
Note: students with disabilities who are unemployed refers to disabled.name who are IN unemployed.name;
Question: Among the students with disabilities, list any five students' names who are unemployed.
SQL: SELECT disabled.name FROM disabled INNER JOIN unemployed ON unemployed.name = disabled.name LIMIT 5
Database: student_loan
Note: unemployed students who filed for bankruptcy refers to unemployed.name who are IN filed_for_bankrupcy.name;
Question: How many unemployed students filed for bankruptcy?
SQL: SELECT count(unemployed.name) FROM unemployed INNER JOIN filed_for_bankrupcy ON filed_for_bankrupcy.name = unemployed.name
Database: student_loan
Note: absent for four months refers to month = 4; enlisted organizations refers to organ;
Question: Among the students who have been absent for four months, provide any five students' names and enlisted organizations.
SQL: SELECT enlist.name, enlist.organ FROM longest_absense_from_school INNER JOIN enlist ON enlist.name = longest_absense_from_school.name WHERE longest_absense_from_school.month = 4 LIMIT 5
Database: student_loan
Note: with payment due refers to bool = 'pos';
Question: Among the students with payment due, how many of them are unemployed?
SQL: SELECT count(no_payment_due.name) FROM no_payment_due INNER JOIN unemployed ON unemployed.name = no_payment_due.name WHERE no_payment_due.bool = 'pos'
Database: student_loan
Note: enlisted organizations refers to organ; student160 is a name of student; status of his or her payment due is mentioned in no_payment_due; bool = 'pos' means the student has payment due; bool = 'neg' means the student has no payment due;
Question: Provide the enlisted organizations of student160 and status of his/her payment due.
SQL: SELECT enlist.organ, no_payment_due.bool FROM enlist INNER JOIN no_payment_due ON no_payment_due.name = enlist.name WHERE enlist.name = 'studenenlist60'
Database: student_loan
Note: male students are mentioned in male.name; foreign legion refers to organ = 'foreign_legion';
Question: List any ten male students who enlisted for foreign legion.
SQL: SELECT enlist.name FROM enlist INNER JOIN male ON male.name = enlist.name WHERE enlist.organ = 'foreign_legion' LIMIT 10
Database: student_loan
Note: percentage = CONCAT(DIVIDE(MULTIPLY(COUNT(person.name which is not in male.name)), 100), COUNT(person.name that is IN male.name),'%'); female students refers to person.name who are NOT in male.name;
Question: Calculate the percentage of female students.
SQL: SELECT cast(sum(iif(male.name IS NULL, 1, 0)) AS REAL) * 100 / count(person.name) FROM person LEFT JOIN male ON male.name = person.name
Database: student_loan
Question: How many students are filed for bankruptcy?
SQL: SELECT count(name) FROM filed_for_bankrupcy
Database: student_loan
Note: smc refers to school = 'smc';
Question: How many students are enrolled in smc during month 1?
SQL: SELECT count(name) FROM enrolled WHERE school = 'smc' AND MONTH = 1
Database: student_loan
Note: organization refers to organ; organ = 'air_force';
Question: How many students enlist in the air force organization?
SQL: SELECT count(name) FROM enlist WHERE organ = 'air_force'
Database: student_loan
Note: organization refers to organ; student168 is a name of student;
Question: What is the organization enlisted by student168?
SQL: SELECT organ FROM enlist WHERE name = 'student168'
Database: student_loan
Note: organization refers to organ; disabled male students refers to disabled.name who are IN male.name;
Question: How many disabled male students joined an organization?
SQL: SELECT count(disabled.name) FROM disabled LEFT JOIN male ON male.name = disabled.name INNER JOIN enlist ON enlist.name = male.name
Database: student_loan
Note: disability breakdown refers to the number of disabled students;
Question: Please provide a disability breakdown for each school.
SQL: SELECT count(enrolled.name) FROM enrolled INNER JOIN disabled ON disabled.name = enrolled.name GROUP BY enrolled.school
Database: student_loan
Note: gender breakdown refers to the number of male and female; male are mentioned in male.name; female refers to enlist.name who are NOT in male.name; organization refers to organ;
Question: Please provide a gender breakdown for each organization.
SQL: SELECT iif(male.name IS NULL, 'female', 'male') AS gender FROM enlist LEFT JOIN male ON male.name = enlist.name GROUP BY enlist.organ
Database: student_loan
Note: enrolled in two schools refers to COUNT(school) = 2; two organizations refers to COUNT(organ) = 2;
Question: List out student names that enrolled in two schools and two organizations?
SQL: SELECT t.name FROM ( SELECT enlist.name, count(enlist.organ) AS num FROM enlist INNER JOIN enrolled ON enlist.name = enrolled.name GROUP BY enlist.name ) t WHERE t.num = 2
Database: student_loan
Note: percentage difference = CONCAT(DIVIDE(MULTIPLY(SUBTRACT(COUNT(name WHERE month = 0), COUNT(name WHERE month = 9)), 100), COUNT(name WHERE month = 0)),'%');
Question: What is the percentage difference between month 0 absence and month 9 absence?
SQL: SELECT cast(((sum(iif(MONTH = 0, 1, 0)) - sum(iif(MONTH = 9, 1, 0)))) AS REAL) * 100 / sum(iif(MONTH = 0, 1, 0)) FROM longest_absense_from_school
Database: student_loan
Note: highest student enrollment refers to MAX(COUNT(school));
Question: Which school have the highest student enrollment? How many of those students are filed for bankruptcy?
SQL: SELECT t.school, num FROM ( SELECT enrolled.school, count(filed_for_bankrupcy.name) AS num FROM enrolled LEFT JOIN filed_for_bankrupcy ON filed_for_bankrupcy.name = enrolled.name GROUP BY enrolled.school ) t ORDER BY t.num DESC LIMIT 1
Database: student_loan
Note: students who are disabled and unemployed at the same time refers to disabled.name = unemployed.name;
Question: How many students is disabled and unemployed at the same time?
SQL: SELECT count(disabled.name) FROM disabled INNER JOIN unemployed ON unemployed.name = disabled.name
Database: student_loan
Note: occ school refers to school = 'occ'; department refers to organ; organ = 'fire_department';
Question: List out students that enrolled in occ school and enlisted in a fire department.
SQL: SELECT enlist.name FROM enlist INNER JOIN enrolled ON enrolled.name = enlist.name WHERE enrolled.school = 'occ' AND enlist.organ = 'fire_department'
Database: student_loan
Note: male students are mentioned in male.name; unemployed and disabled refers to unemployed.name = disabled.name; absent for 5 month refers to month = 5;
Question: Which male students are unemployed, disable and were absent for 5 month?
SQL: SELECT unemployed.name FROM unemployed INNER JOIN disabled ON disabled.name = unemployed.name INNER JOIN longest_absense_from_school ON longest_absense_from_school.name = disabled.name WHERE longest_absense_from_school.month = 5
Database: student_loan
Note: female students refers to enrolled.name who are NOT in male.name; occ school and ulca refers to school IN('occ', 'ulca');
Question: List out female students that enrolled in occ school and ulca?
SQL: SELECT name FROM enrolled WHERE school IN ('occ', 'ulca') AND name NOT IN ( SELECT name FROM male )
Database: student_loan
Note: organization refers to organ; student211 is a name of student;
Question: What is the school and organization enrolled by student211?
SQL: SELECT enrolled.school, enlist.organ FROM enlist INNER JOIN enrolled ON enrolled.name = enlist.name WHERE enlist.name = 'studenenrolled11'