problem
stringlengths 121
422
| db_id
stringclasses 69
values | solution
stringlengths 23
804
|
---|---|---|
Write SQL query to solve given problem: Among students who have been absent for nine months, how many of them are disabled?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM disabled AS T1 LEFT JOIN longest_absense_from_school AS T2 ON T2.name = T1.name WHERE T2.month = 9 |
Write SQL query to solve given problem: List down the student names who did not file for bankruptcy.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT name FROM person WHERE name NOT IN ( SELECT name FROM filed_for_bankrupcy ) |
Write SQL query to solve given problem: List any five female students' names who enlisted for the air force.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT T1.name FROM enlist AS T1 LEFT JOIN male AS T2 ON T2.name = T1.name WHERE T2.name IS NULL AND T1.organ = 'air_force' LIMIT 5 |
Write SQL query to solve given problem: Calculate the number of students who are not disabled.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(CASE WHEN T2.name IS NULL THEN T1.name END) AS "number" FROM person AS T1 LEFT JOIN disabled AS T2 ON T2.name = T1.name |
Write SQL query to solve given problem: Define the gender of "student995" and his/her enrolled schools.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT IIF(T2.name IS NULL, 'female', 'male') AS gen , T1.school FROM enrolled AS T1 LEFT JOIN male AS T2 ON T2.name = T1.name WHERE T1.name = 'student995' |
Write SQL query to solve given problem: Among the students with disabilities, list any five students' names who are unemployed.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT T1.name FROM disabled AS T1 INNER JOIN unemployed AS T2 ON T2.name = T1.name LIMIT 5 |
Write SQL query to solve given problem: How many unemployed students filed for bankruptcy?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM unemployed AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T2.name = T1.name |
Write SQL query to solve given problem: Among the students who have been absent for four months, provide any five students' names and enlisted organizations.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT T2.name, T2.organ FROM longest_absense_from_school AS T1 INNER JOIN enlist AS T2 ON T2.name = T1.name WHERE T1.month = 4 LIMIT 5 |
Write SQL query to solve given problem: Among the students with payment due, how many of them are unemployed?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN unemployed AS T2 ON T2.name = T1.name WHERE T1.bool = 'pos' |
Write SQL query to solve given problem: Provide the enlisted organizations of student160 and status of his/her payment due.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT T1.organ, T2.bool FROM enlist AS T1 INNER JOIN no_payment_due AS T2 ON T2.name = T1.name WHERE T1.name = 'student160' |
Write SQL query to solve given problem: List any ten male students who enlisted for foreign legion.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT T1.name FROM enlist AS T1 INNER JOIN male AS T2 ON T2.name = T1.name WHERE T1.organ = 'foreign_legion' LIMIT 10 |
Write SQL query to solve given problem: Calculate the percentage of female students.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT CAST(SUM(IIF(T2.name IS NULL, 1, 0)) AS REAL) * 100 / COUNT(T1.name) FROM person AS T1 LEFT JOIN male AS T2 ON T2.name = T1.name |
Write SQL query to solve given problem: How many students are filed for bankruptcy?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(name) FROM filed_for_bankrupcy |
Write SQL query to solve given problem: How many students are enrolled in smc during month 1?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(name) FROM enrolled WHERE school = 'smc' AND month = 1 |
Write SQL query to solve given problem: How many students enlist in the air force organization?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(name) FROM enlist WHERE organ = 'air_force' |
Write SQL query to solve given problem: What is the organization enlisted by student168?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT organ FROM enlist WHERE name = 'student168' |
Write SQL query to solve given problem: How many disabled male students joined an organization?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: Please provide a disability breakdown for each school.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM enrolled AS T1 INNER JOIN disabled AS T2 ON T2.name = T1.name GROUP BY T1.school |
Write SQL query to solve given problem: Please provide a gender breakdown for each organization.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: List out student names that enrolled in two schools and two organizations?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: What is the percentage difference between month 0 absence and month 9 absence?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: Which school have the highest student enrollment? How many of those students are filed for bankruptcy?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: How many students is disabled and unemployed at the same time?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM disabled AS T1 INNER JOIN unemployed AS T2 ON T2.name = T1.name |
Write SQL query to solve given problem: List out students that enrolled in occ school and enlisted in a fire department.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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' |
Write SQL query to solve given problem: Which male students are unemployed, disable and were absent for 5 month?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: List out female students that enrolled in occ school and ulca?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT name FROM enrolled WHERE school IN ('occ', 'ulca') AND name NOT IN ( SELECT name FROM male ) |
Write SQL query to solve given problem: What is the school and organization enrolled by student211?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT T2.school, T1.organ FROM enlist AS T1 INNER JOIN enrolled AS T2 ON T2.name = T1.name WHERE T1.name = 'student211' |
Write SQL query to solve given problem: How many male students filed for bankruptcy as compare to female students?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: What is the average absent month for a unemployed male students?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: 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?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 AS T1 LEFT JOIN disabled AS T2 ON T2.name = T1.name |
Write SQL query to solve given problem: Calculate the average duration of absense of disabled male students.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: Calculate the ratio of unemployed students who have never been absent from school.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: State the number of male students who do not have payment due.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN male AS T2 ON T2.name = T1.name WHERE T1.bool = 'pos' |
Write SQL query to solve given problem: State the number of students who filed for bankruptcy and have payment due.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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' |
Write SQL query to solve given problem: What is the status of payment of student 124?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT `bool` FROM no_payment_due WHERE name = 'student124' |
Write SQL query to solve given problem: State the number of disabled students who have payment due.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.bool = 'neg' |
Write SQL query to solve given problem: State name of students who have the longest duration of absense from school and do not have payment due.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: State name of students who have been absent for 5 months from school and do not have payment due.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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' |
Write SQL query to solve given problem: List out the number of disabled students who enlisted in marines.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM disabled AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T2.organ = 'marines' |
Write SQL query to solve given problem: List out the number of students who have the longest duration of absense from school and enlisted in the peace corps.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: List out the number of students who filed for bankruptcy and enlisted in navy.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM enlist AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name WHERE T1.organ = 'navy' |
Write SQL query to solve given problem: Give the number of students who enlisted in marines and have payment due.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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' |
Write SQL query to solve given problem: Calculate the ratio of disabled students who have never been absent from school.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: How many students in the Air Force?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(name) FROM enlist WHERE organ = 'air_force' |
Write SQL query to solve given problem: How many students have been absent less than 4 months?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(name) FROM longest_absense_from_school WHERE month < 4 |
Write SQL query to solve given problem: Count the number of female students who belong to marines organization.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: Calculate the average duration of absense of female students.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: State name of female students who filed for bankruptcy.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: Mention the status of payment of student 299.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT bool FROM no_payment_due WHERE name = 'student299' |
Write SQL query to solve given problem: How many students are enlisted to the air force?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(name) FROM enlist WHERE organ = 'air_force' |
Write SQL query to solve given problem: How many students have absent from school?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(name) FROM longest_absense_from_school WHERE month > 1 |
Write SQL query to solve given problem: Provide the names of the students enlisted in the fire department.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT name FROM enlist WHERE organ = 'fire_department' |
Write SQL query to solve given problem: How many disabled students have payment due?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.bool = 'pos' |
Write SQL query to solve given problem: Among the students that filed for bankruptcy, how many of them have been enrolled in OCC?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM filed_for_bankrupcy AS T1 INNER JOIN enrolled AS T2 ON T1.name = T2.name WHERE T2.school = 'occ' |
Write SQL query to solve given problem: How many disabled students are male?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM male AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name |
Write SQL query to solve given problem: List the names of disabled students enlisted in the navy.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT T1.name FROM enlist AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.organ = 'navy' |
Write SQL query to solve given problem: Among the male students, list down the names of students with payment due.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT T1.name FROM male AS T1 INNER JOIN no_payment_due AS T2 ON T1.name = T2.name WHERE T2.bool = 'pos' |
Write SQL query to solve given problem: What is the employment and payment status of student110?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT T1.bool FROM no_payment_due AS T1 INNER JOIN unemployed AS T2 ON T1.name = T2.name WHERE T1.name = 'student110' |
Write SQL query to solve given problem: Among all students, calculate the percentage of male students.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: What is the school and gender of student34?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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' |
Write SQL query to solve given problem: List the longest duration of absense for a student enlisted in the fire department.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: Among students with 1 month of absenses, how many of them are enlisted in the air force department?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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' |
Write SQL query to solve given problem: Provide the name of disabled male students that are unemployed.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: How many male students are enrolled at OCC?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM enrolled AS T1 INNER JOIN male AS T2 ON T1.name = T2.name WHERE T1.school = 'occ' |
Write SQL query to solve given problem: Among the students enrolled in UCLA, what is the percentage of male students in the air force department?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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' |
Write SQL query to solve given problem: Calculate the average number of disabled female students enrolled in UCI.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: How many students have never been absent in school?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(name) FROM longest_absense_from_school WHERE month = 0 |
Write SQL query to solve given problem: What are the names of the students who joined the Marines?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT name FROM enlist WHERE organ = 'marines' |
Write SQL query to solve given problem: How many students enlisted in the Navy?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(name) FROM enlist WHERE organ = 'navy' |
Write SQL query to solve given problem: What is the name of the student with the longest duration of absence?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT name FROM longest_absense_from_school WHERE month = ( SELECT MAX(month) FROM longest_absense_from_school ) |
Write SQL query to solve given problem: What is the name of the organization which most of the students are enlisted in?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT organ FROM ( SELECT organ, COUNT(organ) AS num FROM enlist GROUP BY organ ) T ORDER BY T.num DESC LIMIT 1 |
Write SQL query to solve given problem: How many students have absences of no more than 3 months?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(name) FROM longest_absense_from_school WHERE month < 3 |
Write SQL query to solve given problem: Among the students that have a payment due, how many students are unemployed?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN unemployed AS T2 ON T1.name = T2.name WHERE T1.bool = 'pos' |
Write SQL query to solve given problem: How many female students have enlisted for the Army?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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' |
Write SQL query to solve given problem: Which organization has the least number of male students?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: How many disabled students have zero absences?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: How many of the unemployed students are disabled?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM unemployed AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name |
Write SQL query to solve given problem: List the names of the disabled students who were absent from school for more than 5 months.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.month > 5 |
Write SQL query to solve given problem: How many bankrupt students are there in the Marines?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM filed_for_bankrupcy AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T2.organ = 'marines' |
Write SQL query to solve given problem: Among the students who filed for bankruptcy, how many students are disabled?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | SELECT COUNT(T1.name) FROM disabled AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name |
Write SQL query to solve given problem: How many months did a student in the Air Force miss school the most?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: 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?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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' |
Write SQL query to solve given problem: How many employed disabled students have zero absences?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: Which organization has the highest number of male students? Calculate for the percentage of the male students in the said organization.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | student_loan | 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 |
Write SQL query to solve given problem: How many users answered "No" to question 19?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | SELECT COUNT(QuestionID) FROM Answer WHERE QuestionID = 19 AND AnswerText LIKE 'No' |
Write SQL query to solve given problem: From 2016 to 2019, how many users each year were asked the question 13?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | SELECT SurveyID, COUNT(UserID) FROM Answer WHERE QuestionID = 13 AND SurveyID BETWEEN 2016 AND 2019 GROUP BY SurveyID |
Write SQL query to solve given problem: How many users, between the age 27 to 35, were surveyed in 2018?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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' |
Write SQL query to solve given problem: In 2019, how many users in the United States have a family history of mental illness?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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 T1.AnswerText LIKE 'United States' |
Write SQL query to solve given problem: Betweeen 2016 to 2019, which year recorded the highest number of people with mental illness?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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 |
Write SQL query to solve given problem: How many female users were surveyed in the mental health survey for 2017 in the state of Nebraska?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID INNER JOIN Survey AS T3 ON T2.SurveyID = T3.SurveyID WHERE T1.questionid = 4 AND T2.AnswerText = 'Nebraska' AND T3.Description = 'mental health survey for 2017' ) |
Write SQL query to solve given problem: How many users believed that their productivity is ever affected by a mental health issue overall?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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' |
Write SQL query to solve given problem: What are the ages of the oldest and youngest user that were surveyed? Indicate their user id.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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 |
Write SQL query to solve given problem: Which country have the least number of users being surveyed? Indicate the name of the country. If there are multiple countries having the same number of users, indicate all of their names.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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 |
Write SQL query to solve given problem: What is the average age of the survey respondents in the United States?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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 = T3.questionid WHERE T3.questionid = 1 |
Write SQL query to solve given problem: What is the percentage of the the users who would bring up a mental health issue with a potential employer in an interview?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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 |
Write SQL query to solve given problem: How many questions in 2014's survey had more than 200 answers?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | SELECT COUNT(QuestionID) FROM Answer WHERE SurveyID LIKE 2014 GROUP BY QuestionID ORDER BY COUNT(QuestionID) > 200 LIMIT 1 |
Write SQL query to solve given problem: What is the oldest age of the users in 2014's survey?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_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 |
Write SQL query to solve given problem: How many users answered "No" to the question "Would you bring up a mental health issue with a potential employer in an interview?" in 2014's survey?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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' |
Write SQL query to solve given problem: Please list the IDs of the users who answered "Yes" to the question "Do you think that discussing a physical health issue with your employer would have negative consequences?" in 2014's survey.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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 |
Write SQL query to solve given problem: How many users participated in the mental health survey for 2014?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | mental_health_survey | 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' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.