Chinastark/bird_dataset huggingface dataset:
Database: student_loan
Note: difference = SUBTRACT(COUNT(filed_for_bankrupcy.name who are In male.name), COUNT(filed_for_bankrupcy.name who are NOT in male.name)); male students are mentioned in male.name; female students refers to filed_for_bankrupy.name who are NOT in male.name;
Question: How many male students filed for bankruptcy as compare to female students?
SQL: SELECT count(male.name) - sum(iif(male.name IS NULL, 1, 0)) AS num FROM filed_for_bankrupcy LEFT JOIN male ON male.name = filed_for_bankrupcy.name
Database: student_loan
Note: average = DIVIDE(SUM(month), COUNT(unemployed.name who are in male.name)); unemployed male students refers to unemployed.name who are IN male.name;
Question: What is the average absent month for a unemployed male students?
SQL: SELECT avg(longest_absense_from_school.month) AS AVG FROM unemployed INNER JOIN longest_absense_from_school ON longest_absense_from_school.name = unemployed.name INNER JOIN male ON male.name = longest_absense_from_school.name
Database: student_loan
Note: difference = MULTIPLY(DIVIDE(SUBTRACT(COUNT(longest_absense_from_school.name that is in disabled.name), COUNT(longest _absense_from_school.name that is NOT in disabled.name), longest _absense_from_school.name), 100)); IF COUNT(longest_absense_from_school.name that is in disabled.name) < COUNT(longest _absense_from_school.name that is NOT in disabled.name), it means, the disabled students have better attendance than non-disabled students; IF COUNT(longest_absense_from_school.name that is in disabled.name) > COUNT(longest _absense_from_school.name that is NOT in disabled.name), it means the disabled students do not have a better attendance than non-disabled students;
Question: What is the percentage difference between the attendence of disabled and non-disable students? Do the disable students show better attendance than non-disable students?
SQL: SELECT cast((sum(iif(disabled.name IS NOT NULL AND longest_absense_from_school.month = 0, 1, 0)) - sum(iif(disabled.name IS NULL AND longest_absense_from_school.month = 0, 1, 0))) AS REAL) * 100 / count(longest_absense_from_school.name), iif(sum(iif(disabled.name IS NOT NULL AND longest_absense_from_school.month = 0, 1, 0)) - sum(iif(disabled.name IS NULL AND longest_absense_from_school.month = 0, 1, 0)) > 0, 'YES', 'NO') AS ishigh FROM longest_absense_from_school LEFT JOIN disabled ON disabled.name = longest_absense_from_school.name
Database: student_loan
Note: average duration = DIVIDE(SUM(month), COUNT(month)); duration of absence refers to month; disabled male students refers to disabled.name who are IN male.name;
Question: Calculate the average duration of absense of disabled male students.
SQL: SELECT avg(longest_absense_from_school.month) FROM longest_absense_from_school INNER JOIN disabled ON disabled.name = longest_absense_from_school.name INNER JOIN male ON male.name = disabled.name
Database: student_loan
Note: ratio = CONCAT(DIVIDE(MULTIPLY(COUNT(unemployed.name WHERE month = 0), 100), COUNT(month)),'%'); unemployed students who have never been absent from school refers to (unemployed.name WHERE month = 0);
Question: Calculate the ratio of unemployed students who have never been absent from school.
SQL: SELECT cast(sum(iif(longest_absense_from_school.month = 0, 1, 0)) AS REAL) * 100 / count(unemployed.name) FROM unemployed INNER JOIN longest_absense_from_school ON longest_absense_from_school.name = unemployed.name
Database: student_loan
Note: do not have payment due refers to bool = 'neg';
Question: State the number of male students who do not have payment due.
SQL: SELECT count(no_payment_due.name) FROM no_payment_due INNER JOIN male ON male.name = no_payment_due.name WHERE no_payment_due.bool = 'pos'
Database: student_loan
Note: have payment due refers to bool = 'pos';
Question: State the number of students who filed for bankruptcy and have payment due.
SQL: SELECT count(filed_for_bankrupcy.name) FROM filed_for_bankrupcy INNER JOIN no_payment_due ON no_payment_due.name = filed_for_bankrupcy.name WHERE no_payment_due.bool = 'pos'
Database: student_loan
Note: status of payment is mentioned in no_payment_due; bool = 'pos' means the student has payment due; bool = 'neg' means the student has no payment due; student124 is a name of student;
Question: What is the status of payment of student 124?
SQL: SELECT `bool` FROM no_payment_due WHERE name = 'student124'
Database: student_loan
Note: have payment due refers to bool = 'pos';
Question: State the number of disabled students who have payment due.
SQL: SELECT count(no_payment_due.name) FROM no_payment_due INNER JOIN disabled ON no_payment_due.name = disabled.name WHERE no_payment_due.bool = 'neg'
Database: student_loan
Note: longest duration of absence from school refers to MAX(month); do not have payment due refers to bool = 'neg';
Question: State name of students who have the longest duration of absense from school and do not have payment due.
SQL: SELECT longest_absense_from_school.name FROM longest_absense_from_school INNER JOIN no_payment_due ON longest_absense_from_school.name = no_payment_due.name WHERE no_payment_due.bool = 'neg' ORDER BY longest_absense_from_school.month DESC LIMIT 1
Database: student_loan
Note: absent for 5 months refers to month = 5; do not have payment due refers to bool = 'neg';
Question: State name of students who have been absent for 5 months from school and do not have payment due.
SQL: SELECT longest_absense_from_school.name FROM longest_absense_from_school INNER JOIN no_payment_due ON longest_absense_from_school.name = no_payment_due.name WHERE longest_absense_from_school.month = 5 AND no_payment_due.bool = 'neg'
Database: student_loan
Note: marines refers to organ = 'marines';
Question: List out the number of disabled students who enlisted in marines.
SQL: SELECT count(disabled.name) FROM disabled INNER JOIN enlist ON disabled.name = enlist.name WHERE enlist.organ = 'marines'
Database: student_loan
Note: longest duration of absence refers to MAX(month); peace corps refers to organ = 'peace_corps';
Question: List out the number of students who have the longest duration of absense from school and enlisted in the peace corps.
SQL: SELECT count(longest_absense_from_school.name) FROM longest_absense_from_school INNER JOIN enlist ON longest_absense_from_school.name = enlist.name WHERE enlist.organ = 'peace_corps' ORDER BY longest_absense_from_school.month DESC LIMIT 1
Database: student_loan
Note: navy refers to organ = 'navy';
Question: List out the number of students who filed for bankruptcy and enlisted in navy.
SQL: SELECT count(enlist.name) FROM enlist INNER JOIN filed_for_bankrupcy ON enlist.name = filed_for_bankrupcy.name WHERE enlist.organ = 'navy'
Database: student_loan
Note: marines refers to organ = 'marines'; have payment due refers to bool = 'pos';
Question: Give the number of students who enlisted in marines and have payment due.
SQL: SELECT count(no_payment_due.name) FROM no_payment_due INNER JOIN enlist ON no_payment_due.name = enlist.name WHERE no_payment_due.bool = 'pos' AND enlist.organ = 'marines'
Database: student_loan
Note: ratio = MULTIPLY(DIVIDE(SUM(month = 0), COUNT(disabled.name)), 100); never been absent from school refers to month = 0;
Question: Calculate the ratio of disabled students who have never been absent from school.
SQL: SELECT 100 * sum(iif(longest_absense_from_school.month = 0, 1, 0)) AS num FROM disabled INNER JOIN longest_absense_from_school ON disabled.name = longest_absense_from_school.name
Database: student_loan
Note: Air Force refers to organ = 'air_force';
Question: How many students in the Air Force?
SQL: SELECT count(name) FROM enlist WHERE organ = 'air_force'
Database: student_loan
Note: absent less than 4 months refers to month < 4;
Question: How many students have been absent less than 4 months?
SQL: SELECT count(name) FROM longest_absense_from_school WHERE MONTH < 4
Database: student_loan
Note: female students refers to enlist.name who are NOT in male.name; organization refers to organ; organ = 'marines';
Question: Count the number of female students who belong to marines organization.
SQL: SELECT count(*) FROM person INNER JOIN enlist ON person.name = enlist.name LEFT JOIN male ON person.name = male.name WHERE enlist.organ = 'marines' AND male.name IS NULL
Database: student_loan
Note: average duration = DIVIDE(SUM(month), COUNT(longest_absence_from_school.name which are NOT in male.name)); female students refers to longest_absence_from_school.name who are NOT in male.name;
Question: Calculate the average duration of absense of female students.
SQL: SELECT avg(longest_absense_from_school.month) FROM person INNER JOIN longest_absense_from_school ON person.name = longest_absense_from_school.name LEFT JOIN male ON person.name = male.name WHERE male.name IS NULL
Database: student_loan
Note: female students refers to filed_for_bankrupcy.name who are NOT in male.name;
Question: State name of female students who filed for bankruptcy.
SQL: SELECT person.name FROM person INNER JOIN filed_for_bankrupcy ON person.name = filed_for_bankrupcy.name LEFT JOIN male ON person.name = male.name WHERE male.name IS NULL
Database: student_loan
Note: status of payment is mentioned in no_payment_due; bool = 'pos' means the student has payment due; bool = 'neg' means the student has no payment due; student299 is a name of student;
Question: Mention the status of payment of student 299.
SQL: SELECT bool FROM no_payment_due WHERE name = 'student299'
Database: student_loan
Note: Air Force refers to organ = 'air_force';
Question: How many students are enlisted to the air force?
SQL: SELECT count(name) FROM enlist WHERE organ = 'air_force'
Database: student_loan
Note: have absent from school refers to month > 1;
Question: How many students have absent from school?
SQL: SELECT count(name) FROM longest_absense_from_school WHERE MONTH > 1
Database: student_loan
Note: department refers to organ; organ = 'fire_department';
Question: Provide the names of the students enlisted in the fire department.
SQL: SELECT name FROM enlist WHERE organ = 'fire_department'
Database: student_loan
Note: payment due refers to bool = 'pos';
Question: How many disabled students have payment due?
SQL: SELECT count(no_payment_due.name) FROM no_payment_due INNER JOIN disabled ON no_payment_due.name = disabled.name WHERE no_payment_due.bool = 'pos'
Database: student_loan
Note: OCC refers to school = 'occ';
Question: Among the students that filed for bankruptcy, how many of them have been enrolled in OCC?
SQL: SELECT count(filed_for_bankrupcy.name) FROM filed_for_bankrupcy INNER JOIN enrolled ON filed_for_bankrupcy.name = enrolled.name WHERE enrolled.school = 'occ'
Database: student_loan
Note: male students are mentioned in male.name;
Question: How many disabled students are male?
SQL: SELECT count(male.name) FROM male INNER JOIN disabled ON male.name = disabled.name
Database: student_loan
Note: navy refers to organ = 'navy';
Question: List the names of disabled students enlisted in the navy.
SQL: SELECT enlist.name FROM enlist INNER JOIN disabled ON enlist.name = disabled.name WHERE enlist.organ = 'navy'
Database: student_loan
Note: male students are mentioned in male.name; with payment due refers to bool = 'pos';
Question: Among the male students, list down the names of students with payment due.
SQL: SELECT male.name FROM male INNER JOIN no_payment_due ON male.name = no_payment_due.name WHERE no_payment_due.bool = 'pos'
Database: student_loan
Note: employment status is mentioned in unemployment; unemployed.name = 'student110' means the student is unemployed; if 'student110' can not be found in unemployed.name, it means the student is employed; payment status is mentioned in no_payment_due; bool = 'pos' means the student has payment due; bool = 'neg' means the student has no payment due; student110 is a name of student;
Question: What is the employment and payment status of student110?
SQL: SELECT no_payment_due.bool FROM no_payment_due INNER JOIN unemployed ON no_payment_due.name = unemployed.name WHERE no_payment_due.name = 'studenno_payment_due10'
Database: student_loan
Note: percentage = MULTIPLY(DIVIDE(COUNT(male.name), COUNT(person.name)), 100); male students are mentioned in male.name;
Question: Among all students, calculate the percentage of male students.
SQL: SELECT cast(count(male.name) AS REAL) * 100 / count(person.name) FROM person LEFT JOIN male ON person.name = male.name
Database: student_loan
Note: male.name = 'student34' means student34's gender is male; if 'student34' can't be found in 'male.name', it means student34 is female; student34 is a name of student;
Question: What is the school and gender of student34?
SQL: SELECT enrolled.school , iif(male.name IS NULL, 'female', 'male') AS gender FROM enrolled INNER JOIN person ON enrolled.name = person.name LEFT JOIN male ON person.name = male.name WHERE person.name = 'studenmale4'
Database: student_loan
Note: longest duration of absence refers to MAX(month); department refers to organ; organ = 'fire_department';
Question: List the longest duration of absense for a student enlisted in the fire department.
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 = 'fire_department' ORDER BY longest_absense_from_school.month DESC LIMIT 1
Database: student_loan
Note: 1 month of absences refers to month = 1; department refers to organ; organ = 'air_force';
Question: Among students with 1 month of absenses, how many of them are enlisted in the air force department?
SQL: SELECT count(longest_absense_from_school.name) FROM longest_absense_from_school INNER JOIN enlist ON longest_absense_from_school.name = enlist.name WHERE longest_absense_from_school.month = 1 AND enlist.organ = 'air_force'
Database: student_loan
Note: disabled male students that are unemployed refers to unemployed.name = male.name = disabled.name;
Question: Provide the name of disabled male students that are unemployed.
SQL: SELECT male.name FROM unemployed INNER JOIN male ON unemployed.name = male.name INNER JOIN disabled ON disabled.name = male.name
Database: student_loan
Note: male students are mentioned in male.name; OCC refers to school = 'occ';
Question: How many male students are enrolled at OCC?
SQL: SELECT count(enrolled.name) FROM enrolled INNER JOIN male ON enrolled.name = male.name WHERE enrolled.school = 'occ'
Database: student_loan
Note: UCLA refers to school = 'ucla'; percentage = MULTIPLY(DIVIDE(COUNT(male.name), COUNT(person.name)), 100); male students are mentioned in male.name; department refers to organ; organ = 'air_force';
Question: Among the students enrolled in UCLA, what is the percentage of male students in the air force department?
SQL: SELECT cast(count(male.name) AS REAL) * 100 / count(person.name) FROM enlist INNER JOIN person ON enlist.name = person.name INNER JOIN enrolled ON enrolled.name = person.name LEFT JOIN male ON person.name = male.name WHERE enrolled.school = 'ucla' AND enlist.organ = 'air_force'
Database: student_loan
Note: average = DIVIDE(SUM(disabled.name who are not in male.name WHERE school = 'uci'), COUNT(enrolled.name)); female students refers to disabled.name who are NOT in male.name; UCI refers to school = 'uci';
Question: Calculate the average number of disabled female students enrolled in UCI.
SQL: SELECT cast(sum(iif(enrolled.school = 'uci' AND male.name IS NULL, 1, 0)) AS REAL) / count(enrolled.name) FROM enrolled INNER JOIN disabled ON enrolled.name = disabled.name INNER JOIN person ON enrolled.name = person.name LEFT JOIN male ON person.name = male.name
Database: student_loan
Note: never been absent in school refers to month = 0;
Question: How many students have never been absent in school?
SQL: SELECT count(name) FROM longest_absense_from_school WHERE MONTH = 0
Database: student_loan
Note: Marines refers to organ = 'marines';
Question: What are the names of the students who joined the Marines?
SQL: SELECT name FROM enlist WHERE organ = 'marines'
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: longest duration of absence refers to MAX(month);
Question: What is the name of the student with the longest duration of absence?
SQL: SELECT name FROM longest_absense_from_school WHERE MONTH = ( SELECT max(MONTH) FROM longest_absense_from_school )
Database: student_loan
Note: name of the organization refers to organ; organization which most of the students are enlisted in refers to MAX(COUNT(organ));
Question: What is the name of the organization which most of the students are enlisted in?
SQL: SELECT organ FROM ( SELECT organ, count(organ) AS num FROM enlist GROUP BY organ ) t ORDER BY t.num DESC LIMIT 1
Database: student_loan
Note: absences of no more than 3 months refers to month < 3;
Question: How many students have absences of no more than 3 months?
SQL: SELECT count(name) FROM longest_absense_from_school WHERE MONTH < 3
Database: student_loan
Note: students that have a payment due refers to bool = 'pos';
Question: Among the students that have a payment due, how many students are unemployed?
SQL: SELECT count(no_payment_due.name) FROM no_payment_due INNER JOIN unemployed ON no_payment_due.name = unemployed.name WHERE no_payment_due.bool = 'pos'
Database: student_loan
Note: female students refers to enlist.name who are NOT in male.name; Army refers to organ = 'army';
Question: How many female students have enlisted for the Army?
SQL: SELECT sum(iif(male.name IS NULL, 1, 0)) AS "result" FROM enlist INNER JOIN person ON enlist.name = person.name LEFT JOIN male ON person.name = male.name WHERE enlist.organ = 'army'
Database: student_loan
Note: organization refers to organ; male students are mentioned in male.name; least number of male students refers to MIN(male.name);
Question: Which organization has the least number of male students?
SQL: SELECT t.organ FROM ( SELECT enlist.organ, count(male.name) AS num FROM male INNER JOIN enlist ON male.name = enlist.name GROUP BY enlist.organ ) t ORDER BY t.num LIMIT 1
Database: student_loan
Note: zero absences refers to month = 0;
Question: How many disabled students have zero absences?
SQL: SELECT count(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
Question: How many of the unemployed students are disabled?
SQL: SELECT count(unemployed.name) FROM unemployed INNER JOIN disabled ON unemployed.name = disabled.name
Database: student_loan
Note: absent for more than 5 months refers to month > 5;
Question: List the names of the disabled students who were absent from school for more than 5 months.
SQL: SELECT 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 > 5
Database: student_loan
Note: Marines refers to organ = 'marines';
Question: How many bankrupt students are there in the Marines?
SQL: SELECT count(filed_for_bankrupcy.name) FROM filed_for_bankrupcy INNER JOIN enlist ON filed_for_bankrupcy.name = enlist.name WHERE enlist.organ = 'marines'
Database: student_loan
Question: Among the students who filed for bankruptcy, how many students are disabled?
SQL: SELECT count(disabled.name) FROM disabled INNER JOIN filed_for_bankrupcy ON disabled.name = filed_for_bankrupcy.name
Database: student_loan
Note: Air Force refers to organ = 'air_force'; number of months a student miss school the most refers to MAX(COUNT(month));
Question: How many months did a student in the Air Force miss school the most?
SQL: SELECT longest_absense_from_school.month FROM longest_absense_from_school INNER JOIN enlist ON longest_absense_from_school.name = enlist.name ORDER BY longest_absense_from_school.month DESC LIMIT 1
Database: student_loan
Note: absence of no more than 6 months refers to month < 6; department refers to organ; organ = 'fire_department';
Question: Among the students who filed for bankruptcy with an absence in school of no more than 6 months, how many students enlisted for the fire department?
SQL: SELECT count(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 INNER JOIN enlist ON enlist.name = filed_for_bankrupcy.name WHERE enlist.organ = 'fire_department'
Database: student_loan
Note: employed students refers to disabled.name who are NOT in unemployed.name; zero absences refers to month = 0;
Question: How many employed disabled students have zero absences?
SQL: SELECT count(longest_absense_from_school.name) FROM longest_absense_from_school INNER JOIN disabled ON longest_absense_from_school.name = disabled.name INNER JOIN unemployed ON unemployed.name = disabled.name WHERE longest_absense_from_school.month = 0
Database: student_loan
Note: organization refers to organ; highest number of male students refers to MAX(COUNT(male.name)); percentage = DIVIDE(COUNT(male.name), COUNT(person.name)), 1.0;
Question: Which organization has the highest number of male students? Calculate for the percentage of the male students in the said organization.
SQL: SELECT t.organ, t.per FROM ( SELECT enlist.organ, cast(count(male.name) AS REAL) / count(person.name) AS per , count(male.name) AS num FROM enlist INNER JOIN person ON enlist.name = person.name LEFT JOIN male ON person.name = male.name GROUP BY enlist.organ ) t ORDER BY t.num DESC LIMIT 1
Database: mental_health_survey
Note: question 19 refer to questionid = 19; No refer to answertext = 'No';
Question: How many users answered "No" to question 19?
SQL: SELECT count(questionid) FROM answer WHERE questionid = 19 AND answertext LIKE 'No'
Database: mental_health_survey
Note: From 2016 to 2019 refer to surveyid 2016 BETWEEN 2019; question 13 refer to questionid;
Question: From 2016 to 2019, how many users each year were asked the question 13?
SQL: SELECT surveyid, count(userid) FROM answer WHERE questionid = 13 AND surveyid BETWEEN 2016 AND 2019 GROUP BY surveyid
Database: mental_health_survey
Note: Age 27 to 35 refer to answertext 27 BETWEEN 35 where questionid = 1; 2018 refer to surveyid;
Question: How many users, between the age 27 to 35, were surveyed in 2018?
SQL: SELECT answer.userid FROM answer INNER JOIN question ON answer.questionid = question.questionid WHERE answer.surveyid = 2018 AND question.questionid = 1 AND answer.answertext BETWEEN '27' AND '35'
Database: mental_health_survey
Note: 2019 refer to surveyid; Users in the United States refers to answertext = 'United States' where questionid = 3; have a family history of mental illness refers to answertext = 'Yes' where questionid = 6;
Question: In 2019, how many users in the United States have a family history of mental illness?
SQL: SELECT count(answer.userid) FROM answer INNER JOIN ( SELECT question.questionid FROM answer INNER JOIN question ON answer.questionid = question.questionid WHERE answer.surveyid = 2019 AND question.questionid = 6 AND answer.answertext LIKE 'Yes' ) ON answer.questionid = question.questionid WHERE answer.surveyid = 2019 AND question.questionid = 3 AND answer.answertext LIKE 'United States'
Database: mental_health_survey
Note: Between 2016 to 2019 refer to surveyid 2016 BETWEEN 2019; People with mental illness refers to answertext = 'Yes' where questionid = 34;
Question: Betweeen 2016 to 2019, which year recorded the highest number of people with mental illness?
SQL: SELECT answer.surveyid FROM answer INNER JOIN question ON answer.questionid = question.questionid WHERE answer.surveyid BETWEEN 2016 AND 2019 AND question.questionid = 34 AND answer.answertext LIKE 'Yes' GROUP BY answer.surveyid ORDER BY count(answer.userid) DESC LIMIT 1