input
stringlengths
122
2.7k
output
stringlengths
24
805
[INST] Here is a database schema: enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: How many students are enrolled in smc during month 1? [/INST] [/INST]
SELECT COUNT(name) FROM enrolled WHERE school = 'smc' AND month = 1;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: How many students enlist in the air force organization? [/INST] [/INST]
SELECT COUNT(name) FROM enlist WHERE organ = 'air_force';
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: What is the organization enlisted by student168? [/INST] [/INST]
SELECT organ FROM enlist WHERE name = 'student168';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: How many disabled male student...
SELECT COUNT(T1.name) FROM disabled AS T1 LEFT JOIN male AS T2 ON T2.name = T1.name INNER JOIN enlist AS T3 ON T3.name = T2.name;
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: Please provide a disability breakdown for each school. [/INST] [...
SELECT COUNT(T1.name) FROM enrolled AS T1 INNER JOIN disabled AS T2 ON T2.name = T1.name GROUP BY T1.school;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: Please provide a gender breakdown for each organization. [/INST] [/INST]
SELECT IIF(T2.name IS NULL, 'female', 'male') AS gender FROM enlist AS T1 LEFT JOIN male AS T2 ON T2.name = T1.name GROUP BY T1.organ;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: List out student names that enrolled in two schools and two organ...
SELECT T.name FROM ( SELECT T1.name, COUNT(T1.organ) AS num FROM enlist AS T1 INNER JOIN enrolled AS T2 ON T1.name = T2.name GROUP BY T1.name ) T WHERE T.num = 2;
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: What is the percentage difference between month 0 absence and month 9 absence? [/INST] [/INST]
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;
[INST] Here is a database schema: filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: Which school have the highest student enro...
SELECT T.school, num FROM ( SELECT T1.school, COUNT(T2.name) AS num FROM enrolled AS T1 LEFT JOIN filed_for_bankrupcy AS T2 ON T2.name = T1.name GROUP BY T1.school ) T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statement that answers the following question: How many students is disabled and unemployed at the same time? [/INST] [/INST]
SELECT COUNT(T1.name) FROM disabled AS T1 INNER JOIN unemployed AS T2 ON T2.name = T1.name;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: List out students that enrolled in occ school and enlisted in a f...
SELECT T1.name FROM enlist AS T1 INNER JOIN enrolled AS T2 ON T2.name = T1.name WHERE T2.school = 'occ' AND T1.organ = 'fire_department';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statemen...
SELECT T1.name FROM unemployed AS T1 INNER JOIN disabled AS T2 ON T2.name = T1.name INNER JOIN longest_absense_from_school AS T3 ON T3.name = T2.name WHERE T3.month = 5;
[INST] Here is a database schema: male : name [ TEXT ] primary_key male.name = person.name enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: List out female students that enrolled in occ school and ulca? [/INST] [...
SELECT name FROM enrolled WHERE school IN ('occ', 'ulca') AND name NOT IN ( SELECT name FROM male );
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: What is the school and organization enrolled by student211? [/INS...
SELECT T2.school, T1.organ FROM enlist AS T1 INNER JOIN enrolled AS T2 ON T2.name = T1.name WHERE T1.name = 'student211';
[INST] Here is a database schema: filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: How many male students filed for bankruptcy as compare to female student...
SELECT COUNT(T2.name) - SUM(IIF(T2.name IS NULL, 1, 0)) AS num FROM filed_for_bankrupcy AS T1 LEFT JOIN male AS T2 ON T2.name = T1.name;
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] male : name [ TEXT ] primary_key male.name = person.name unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statement that a...
SELECT AVG(T2.month) AS avg FROM unemployed AS T1 INNER JOIN longest_absense_from_school AS T2 ON T2.name = T1.name INNER JOIN male AS T3 ON T3.name = T2.name;
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: What is the percentage differe...
SELECT CAST((SUM(IIF(T2.name IS NOT NULL AND T1.month = 0, 1, 0)) - SUM(IIF(T2.name IS NULL AND T1.month = 0, 1, 0))) AS REAL) * 100 / COUNT(T1.name), IIF(SUM(IIF(T2.name IS NOT NULL AND T1.month = 0, 1, 0)) - SUM(IIF(T2.name IS NULL AND T1.month = 0, 1, 0)) > 0, 'YES', 'NO') AS isHigh FROM longest_absense_from_school ...
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answe...
SELECT AVG(T1.month) FROM longest_absense_from_school AS T1 INNER JOIN disabled AS T2 ON T2.name = T1.name INNER JOIN male AS T3 ON T3.name = T2.name;
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statement that answers the following question: Calculate the ratio of une...
SELECT CAST(SUM(IIF(T2.month = 0, 1, 0)) AS REAL) * 100 / COUNT(T1.name) FROM unemployed AS T1 INNER JOIN longest_absense_from_school AS T2 ON T2.name = T1.name;
[INST] Here is a database schema: male : name [ TEXT ] primary_key male.name = person.name no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name Please write me a SQL statement that answers the following question: State the number of male students wh...
SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN male AS T2 ON T2.name = T1.name WHERE T1.bool = 'pos';
[INST] Here is a database schema: filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name Please write me a SQL statement that answers the following question: State ...
SELECT COUNT(T1.name) FROM filed_for_bankrupcy AS T1 INNER JOIN no_payment_due AS T2 ON T2.name = T1.name WHERE T2.bool = 'pos';
[INST] Please write me a SQL statement that answers the following question: What is the status of payment of student 124? [/INST] [/INST]
SELECT `bool` FROM no_payment_due WHERE name = 'student124';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name Please write me a SQL statement that answers the following question: State the number of disabled...
SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.bool = 'neg';
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name Please write me a SQL statement that answ...
SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN no_payment_due AS T2 ON T1.name = T2.name WHERE T2.bool = 'neg' ORDER BY T1.month DESC LIMIT 1;
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name Please write me a SQL statement that answ...
SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN no_payment_due AS T2 ON T1.name = T2.name WHERE T1.month = 5 AND T2.bool = 'neg';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: List out the number of disabled students who enlisted in marines. [/INST] [/INST]
SELECT COUNT(T1.name) FROM disabled AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T2.organ = 'marines';
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: List out the number of students...
SELECT COUNT(T1.NAME) FROM longest_absense_from_school AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T2.organ = 'peace_corps' ORDER BY T1.month DESC LIMIT 1;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name Please write me a SQL statement that answers the following question: List out the number of students who filed for bankruptcy and enli...
SELECT COUNT(T1.name) FROM enlist AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name WHERE T1.organ = 'navy';
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name Please write me a SQL statement that answers the following question: Give the number of students w...
SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T1.bool = 'pos' AND T2.organ = 'marines';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the ratio of disable...
SELECT 100 * SUM(IIF(T2.month = 0, 1, 0)) AS num FROM disabled AS T1 INNER JOIN longest_absense_from_school AS T2 ON T1.name = T2.name;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: How many students in the Air Force? [/INST] [/INST]
SELECT COUNT(name) FROM enlist WHERE organ = 'air_force';
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: How many students have been absent less than 4 months? [/INST] [/INST]
SELECT COUNT(name) FROM longest_absense_from_school WHERE month < 4;
[INST] Here is a database schema: person : name [ TEXT ] primary_key enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: Count the number of female students who belong to marines or...
SELECT COUNT(*) FROM person AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name LEFT JOIN male AS T3 ON T1.name = T3.name WHERE T2.organ = 'marines' AND T3.name IS NULL;
[INST] Here is a database schema: person : name [ TEXT ] primary_key longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: Cal...
SELECT AVG(T2.month) FROM person AS T1 INNER JOIN longest_absense_from_school AS T2 ON T1.name = T2.name LEFT JOIN male AS T3 ON T1.name = T3.name WHERE T3.name IS NULL;
[INST] Here is a database schema: person : name [ TEXT ] primary_key filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: State name of female students who fil...
SELECT T1.name FROM person AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name LEFT JOIN male AS T3 ON T1.name = T3.name WHERE T3.name IS NULL;
[INST] Here is a database schema: no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name Please write me a SQL statement that answers the following question: Mention the status of payment of student 299. [/INST] [/INST]
SELECT bool FROM no_payment_due WHERE name = 'student299';
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: How many students are enlisted to the air force? [/INST] [/INST]
SELECT COUNT(name) FROM enlist WHERE organ = 'air_force';
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: How many students have absent from school? [/INST] [/INST]
SELECT COUNT(name) FROM longest_absense_from_school WHERE month > 1;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: Provide the names of the students enlisted in the fire department. [/INST] [/INST]
SELECT name FROM enlist WHERE organ = 'fire_department';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name Please write me a SQL statement that answers the following question: How many disabled students h...
SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.bool = 'pos';
[INST] Here is a database schema: filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: Among the students that filed for bankrupt...
SELECT COUNT(T1.name) FROM filed_for_bankrupcy AS T1 INNER JOIN enrolled AS T2 ON T1.name = T2.name WHERE T2.school = 'occ';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: How many disabled students are male? [/INST] [/INST]
SELECT COUNT(T1.name) FROM male AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name;
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: List the names of disabled students enlisted in the navy. [/INST] [/INST]
SELECT T1.name FROM enlist AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.organ = 'navy';
[INST] Here is a database schema: male : name [ TEXT ] primary_key male.name = person.name no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name Please write me a SQL statement that answers the following question: Among the male students, list down t...
SELECT T1.name FROM male AS T1 INNER JOIN no_payment_due AS T2 ON T1.name = T2.name WHERE T2.bool = 'pos';
[INST] Here is a database schema: no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statement that answers the following question: What is the employment a...
SELECT T1.bool FROM no_payment_due AS T1 INNER JOIN unemployed AS T2 ON T1.name = T2.name WHERE T1.name = 'student110';
[INST] Here is a database schema: person : name [ TEXT ] primary_key male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: Among all students, calculate the percentage of male students. [/INST] [/INST]
SELECT CAST(COUNT(T2.name) AS REAL) * 100 / COUNT(T1.name) FROM person AS T1 LEFT JOIN male AS T2 ON T1.name = T2.name;
[INST] Here is a database schema: person : name [ TEXT ] primary_key male : name [ TEXT ] primary_key male.name = person.name enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: What is the school and gender of stud...
SELECT T1.school , IIF(T3.name IS NULL, 'female', 'male') AS gender FROM enrolled AS T1 INNER JOIN person AS T2 ON T1.name = T2.name LEFT JOIN male AS T3 ON T2.name = T3.name WHERE T2.name = 'student34';
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: List the longest duration of ab...
SELECT T1.month FROM longest_absense_from_school AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T2.organ = 'fire_department' ORDER BY T1.month DESC LIMIT 1;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: Among students with 1 month of ...
SELECT COUNT(T1.name) FROM longest_absense_from_school AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T1.month = 1 AND T2.organ = 'air_force';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name male : name [ TEXT ] primary_key male.name = person.name unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statement that answers the following question: Provide the name of disab...
SELECT T2.NAME FROM unemployed AS T1 INNER JOIN male AS T2 ON T1.name = T2.name INNER JOIN disabled AS T3 ON T3.name = T2.name;
[INST] Here is a database schema: male : name [ TEXT ] primary_key male.name = person.name enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: How many male students are enrolled at OCC? [/INST] [/INST]
SELECT COUNT(T1.name) FROM enrolled AS T1 INNER JOIN male AS T2 ON T1.name = T2.name WHERE T1.school = 'occ';
[INST] Here is a database schema: person : name [ TEXT ] primary_key enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] male : name [ TEXT ] primary_key male.name = person.name enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answe...
SELECT CAST(COUNT(T4.name) AS REAL) * 100 / COUNT(T2.name) FROM enlist AS T1 INNER JOIN person AS T2 ON T1.name = T2.name INNER JOIN enrolled AS T3 ON T3.name = T2.name LEFT JOIN male AS T4 ON T2.name = T4.name WHERE T3.school = 'ucla' AND T1.organ = 'air_force';
[INST] Here is a database schema: person : name [ TEXT ] primary_key disabled : name [ TEXT ] primary_key disabled.name = person.name male : name [ TEXT ] primary_key male.name = person.name enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answ...
SELECT CAST(SUM(IIF(T1.school = 'uci' AND T4.name IS NULL, 1, 0)) AS REAL) / COUNT(T1.name) FROM enrolled AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name INNER JOIN person AS T3 ON T1.name = T3.name LEFT JOIN male AS T4 ON T3.name = T4.name;
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: How many students have never been absent in school? [/INST] [/INST]
SELECT COUNT(name) FROM longest_absense_from_school WHERE month = 0;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: What are the names of the students who joined the Marines? [/INST] [/INST]
SELECT name FROM enlist WHERE organ = 'marines';
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: How many students enlisted in the Navy? [/INST] [/INST]
SELECT COUNT(name) FROM enlist WHERE organ = 'navy';
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: What is the name of the student with the longest duration of absence? [/INST] [/INST]
SELECT name FROM longest_absense_from_school WHERE month = ( SELECT MAX(month) FROM longest_absense_from_school );
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: What is the name of the organization which most of the students are enlisted in? [/INST] [/INST]
SELECT organ FROM ( SELECT organ, COUNT(organ) AS num FROM enlist GROUP BY organ ) T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: How many students have absences of no more than 3 months? [/INST] [/INST]
SELECT COUNT(name) FROM longest_absense_from_school WHERE month < 3;
[INST] Here is a database schema: no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statement that answers the following question: Among the students that ...
SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN unemployed AS T2 ON T1.name = T2.name WHERE T1.bool = 'pos';
[INST] Here is a database schema: person : name [ TEXT ] primary_key enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: How many female students have enlisted for the Army? [/INST]...
SELECT SUM(IIF(T3.name IS NULL, 1, 0)) AS "result" FROM enlist AS T1 INNER JOIN person AS T2 ON T1.name = T2.name LEFT JOIN male AS T3 ON T2.name = T3.name WHERE T1.organ = 'army';
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: Which organization has the least number of male students? [/INST] [/INST]
SELECT T.organ FROM ( SELECT T2.organ, COUNT(T1.name) AS num FROM male AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name GROUP BY T2.organ ) T ORDER BY T.num LIMIT 1;
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: How many disabled students hav...
SELECT COUNT(T1.name) FROM disabled AS T1 INNER JOIN longest_absense_from_school AS T2 ON T1.name = T2.name WHERE T2.month = 0;
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statement that answers the following question: How many of the unemployed students are disabled? [/INST] [/INST]
SELECT COUNT(T1.name) FROM unemployed AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name;
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: List the names of the disabled...
SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.month > 5;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name Please write me a SQL statement that answers the following question: How many bankrupt students are there in the Marines? [/INST] [/IN...
SELECT COUNT(T1.name) FROM filed_for_bankrupcy AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T2.organ = 'marines';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name Please write me a SQL statement that answers the following question: Among the students who filed for bankruptcy, how many students a...
SELECT COUNT(T1.name) FROM disabled AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: How many months did a student i...
SELECT T1.month FROM longest_absense_from_school AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name ORDER BY T1.month DESC LIMIT 1;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write ...
SELECT COUNT(T1.name) FROM longest_absense_from_school AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name INNER JOIN enlist AS T3 ON T3.name = T2.name WHERE T3.organ = 'fire_department';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statemen...
SELECT COUNT(T1.name) FROM longest_absense_from_school AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name INNER JOIN unemployed AS T3 ON T3.name = T2.name WHERE T1.month = 0;
[INST] Here is a database schema: person : name [ TEXT ] primary_key enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: Which organization has the highest number of male students? ...
SELECT T.organ, T.per FROM ( SELECT T1.organ, CAST(COUNT(T3.name) AS REAL) / COUNT(T2.name) AS per , COUNT(T3.name) AS num FROM enlist AS T1 INNER JOIN person AS T2 ON T1.name = T2.name LEFT JOIN male AS T3 ON T2.name = T3.name GROUP BY T1.organ ) T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: How many users answered "No" to question 19? [/INST] [/INST]
SELECT COUNT(QuestionID) FROM Answer WHERE QuestionID = 19 AND AnswerText LIKE 'No';
[INST] Here is a database schema: Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: From 2016 to 2019, how many users each year were asked the question 13? [/INST] [/INST]
SELECT SurveyID, COUNT(UserID) FROM Answer WHERE QuestionID = 13 AND SurveyID BETWEEN 2016 AND 2019 GROUP BY SurveyID;
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: How many users, between the age 27 to 35, were surveyed ...
SELECT T1.UserID FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T1.SurveyID = 2018 AND T2.questionid = 1 AND T1.AnswerText BETWEEN '27' AND '35';
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: In 2019, how many users in the United States have a fami...
SELECT COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN ( SELECT T2.questionid FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T1.SurveyID = 2019 AND T2.questionid = 6 AND T1.AnswerText LIKE 'Yes' ) AS T2 ON T1.QuestionID = T2.questionid WHERE T1.SurveyID = 2019 AND T2.questionid = 3 AND...
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: Betweeen 2016 to 2019, which year recorded the highest n...
SELECT T1.SurveyID FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T1.SurveyID BETWEEN 2016 AND 2019 AND T2.questionid = 34 AND T1.AnswerText LIKE 'Yes' GROUP BY T1.SurveyID ORDER BY COUNT(T1.UserID) DESC LIMIT 1;
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Survey : SurveyID [ INTEGER ] primary_key Description [ TEXT ] Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following que...
SELECT COUNT(*) FROM ( SELECT T2.UserID FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID INNER JOIN Survey AS T3 ON T2.SurveyID = T3.SurveyID WHERE T3.Description = 'mental health survey for 2017' AND T1.questionid = 2 AND T2.AnswerText = 'Female' UNION SELECT T2.UserID FROM Question AS T1 I...
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: How many users believed that their productivity is ever ...
SELECT COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questionid = 54 AND T1.AnswerText LIKE 'Yes';
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: What are the ages of the oldest and youngest user that w...
SELECT MAX(T1.AnswerText), MIN(T1.AnswerText) , ( SELECT T1.UserID FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questionid = 1 ORDER BY T1.AnswerText LIMIT 1 ) AS "youngest id" FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questionid = 1;
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: Which country have the least number of users being surve...
SELECT T1.AnswerText FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questionid = 3 GROUP BY T1.AnswerText ORDER BY COUNT(T1.UserID) DESC LIMIT 1;
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average age of the survey respondents in the...
SELECT CAST(SUM(T1.AnswerText) AS REAL) / COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN ( SELECT T1.UserID FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questionid = 3 AND T1.AnswerText = 'United States' ) AS T2 ON T1.UserID = T2.UserID INNER JOIN Question AS T3 ON T1.QuestionID ...
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: What is the percentage of the the users who would bring ...
SELECT CAST(SUM(CASE WHEN T1.AnswerText LIKE 'Yes' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questionid = 12;
[INST] Here is a database schema: Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: How many questions in 2014's survey had more than 200 answers? [/INST] [/INST]
SELECT COUNT(QuestionID) FROM Answer WHERE SurveyID LIKE 2014 GROUP BY QuestionID ORDER BY COUNT(QuestionID) > 200 LIMIT 1;
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: What is the oldest age of the users in 2014's survey? [/...
SELECT T2.AnswerText FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID WHERE T1.questiontext = 'What is your age?' AND T2.SurveyID = 2014 ORDER BY T2.AnswerText DESC LIMIT 1;
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: How many users answered "No" to the question "Would you ...
SELECT COUNT(T2.UserID) FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID WHERE T1.questiontext = 'Would you bring up a mental health issue with a potential employer in an interview?' AND T2.SurveyID = 2014 AND T2.AnswerText LIKE 'NO';
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: Please list the IDs of the users who answered "Yes" to t...
SELECT T2.UserID FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID WHERE T1.questiontext = 'Do you think that discussing a physical health issue with your employer would have negative consequences?' AND T2.AnswerText LIKE 'Yes' AND T2.SurveyID = 2014;
[INST] Here is a database schema: Survey : SurveyID [ INTEGER ] primary_key Description [ TEXT ] Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: How many users participated in the mental health survey for 2...
SELECT COUNT(DISTINCT T1.UserID) FROM Answer AS T1 INNER JOIN Survey AS T2 ON T1.SurveyID = T2.SurveyID WHERE T2.Description = 'mental health survey for 2014';
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: Please list all the answers to the question "Any additio...
SELECT T2.AnswerText FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID WHERE T1.questiontext = 'Any additional notes or comments' AND T2.SurveyID = 2014 AND T2.AnswerText <> -1;
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: Please list all the common questions in 2014's survey an...
SELECT T1.questiontext FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID WHERE T2.SurveyID IN (2014, 2016) GROUP BY T1.questiontext;
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: How many users lived in Canada according to 2018's surve...
SELECT COUNT(T2.UserID) FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID WHERE T2.SurveyID = 2018 AND T1.questiontext = 'What country do you live in?' AND T2.AnswerText = 'Canada';
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Survey : SurveyID [ INTEGER ] primary_key Description [ TEXT ] Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following que...
SELECT T2.questiontext FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid INNER JOIN Survey AS T3 ON T1.SurveyID = T3.SurveyID WHERE T3.Description LIKE 'mental health survey for 2014' GROUP BY T2.questiontext;
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: According to 2016's survey, what is the number of users ...
SELECT COUNT(T2.UserID) FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID WHERE T2.SurveyID = 2016 AND T1.questiontext LIKE 'Have you had a mental health disorder in the past?' AND T2.AnswerText = 'Yes';
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: How many users answered "Yes" to the question "Have you ...
SELECT COUNT(T2.UserID) FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID WHERE T2.SurveyID IN (2016, 2017, 2018) AND T1.questiontext LIKE 'Have you had a mental health disorder in the past?' AND T2.AnswerText = 'Yes';
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average result of the question "What is your...
SELECT CAST(SUM(T2.AnswerText) AS REAL) / COUNT(T2.UserID) AS "avg" FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID WHERE T2.SurveyID = 2014 AND T1.questiontext LIKE 'What is your age?';
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: What is the rate of increase of users with a current men...
SELECT CAST(( SELECT COUNT(T2.UserID) FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID WHERE T2.SurveyID = 2019 AND T1.questiontext LIKE 'Do you currently have a mental health disorder?' AND T2.AnswerText = 'Yes' ) - ( SELECT COUNT(T2.UserID) FROM Question AS T1 INNER JOIN Answer AS T2 ON T1...
[INST] Here is a database schema: Question : questiontext [ TEXT ] questionid [ INTEGER ] primary_key Please write me a SQL statement that answers the following question: Tell the question ID for "Would you bring up a physical health issue with a potential employer in an interview?". [/INST] [/INST]
SELECT questionid FROM Question WHERE questiontext LIKE 'Would you bring up a physical health issue with a potential employer in an interview?';
[INST] Here is a database schema: Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: How many users answered the question No.20? [/INST] [/INST]
SELECT MAX(UserID) - MIN(UserID) + 1 FROM Answer WHERE QuestionID = 20;
[INST] Here is a database schema: Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: How many questions did user No.5 answer? [/INST] [/INST]
SELECT COUNT(QuestionID) FROM Answer WHERE UserID = 5;
[INST] Here is a database schema: Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: How many users participated in the Survey No.2016? [/INST] [/INST]
SELECT COUNT(DISTINCT UserID) FROM Answer WHERE SurveyID LIKE 2016;
[INST] Here is a database schema: Survey : SurveyID [ INTEGER ] primary_key Description [ TEXT ] Answer : AnswerText [ TEXT ] SurveyID [ INTEGER ] UserID [ INTEGER ] QuestionID [ INTEGER ] Please write me a SQL statement that answers the following question: State the number of questions that were asked in the "mental ...
SELECT COUNT(T1.QuestionID) FROM Answer AS T1 INNER JOIN Survey AS T2 ON T1.SurveyID = T2.SurveyID WHERE T2.Description = 'mental health survey for 2018';