Dludora/DAIL-BIRD huggingface dataset:
/* Given the following database schema: */
CREATE TABLE bool
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE person
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE disabled
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE enlist
(
    "name"  TEXT not null,
    organ TEXT not null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE filed_for_bankrupcy
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE longest_absense_from_school
(
    "name"  TEXT default '' not null
        primary key,
    "month" INTEGER       default 0  null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE male
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE no_payment_due
(
    "name" TEXT default '' not null
        primary key,
    bool TEXT             null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade,
        foreign key (bool) references bool ("name")
            on update cascade on delete cascade
)

CREATE TABLE unemployed
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE `enrolled` (
  `name` TEXT NOT NULL,
  `school` TEXT NOT NULL,
  `month` INTEGER NOT NULL DEFAULT 0,
  PRIMARY KEY (`name`,`school`),
  FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
)

/* Answer the following: List the names of the disabled students who were absent from school for more than 5 months. absent for more than 5 months refers to month > 5; */
SELECT 
SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.month > 5
/* Given the following database schema: */
CREATE TABLE bool
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE person
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE disabled
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE enlist
(
    "name"  TEXT not null,
    organ TEXT not null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE filed_for_bankrupcy
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE longest_absense_from_school
(
    "name"  TEXT default '' not null
        primary key,
    "month" INTEGER       default 0  null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE male
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE no_payment_due
(
    "name" TEXT default '' not null
        primary key,
    bool TEXT             null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade,
        foreign key (bool) references bool ("name")
            on update cascade on delete cascade
)

CREATE TABLE unemployed
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE `enrolled` (
  `name` TEXT NOT NULL,
  `school` TEXT NOT NULL,
  `month` INTEGER NOT NULL DEFAULT 0,
  PRIMARY KEY (`name`,`school`),
  FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
)

/* Answer the following: How many bankrupt students are there in the Marines? Marines refers to organ = 'marines'; */
SELECT 
SELECT COUNT(T1.name) FROM filed_for_bankrupcy AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T2.organ = 'marines'
/* Given the following database schema: */
CREATE TABLE bool
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE person
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE disabled
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE enlist
(
    "name"  TEXT not null,
    organ TEXT not null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE filed_for_bankrupcy
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE longest_absense_from_school
(
    "name"  TEXT default '' not null
        primary key,
    "month" INTEGER       default 0  null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE male
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE no_payment_due
(
    "name" TEXT default '' not null
        primary key,
    bool TEXT             null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade,
        foreign key (bool) references bool ("name")
            on update cascade on delete cascade
)

CREATE TABLE unemployed
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE `enrolled` (
  `name` TEXT NOT NULL,
  `school` TEXT NOT NULL,
  `month` INTEGER NOT NULL DEFAULT 0,
  PRIMARY KEY (`name`,`school`),
  FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
)

/* Answer the following: Among the students who filed for bankruptcy, how many students are disabled? */
SELECT 
SELECT COUNT(T1.name) FROM disabled AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name
/* Given the following database schema: */
CREATE TABLE bool
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE person
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE disabled
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE enlist
(
    "name"  TEXT not null,
    organ TEXT not null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE filed_for_bankrupcy
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE longest_absense_from_school
(
    "name"  TEXT default '' not null
        primary key,
    "month" INTEGER       default 0  null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE male
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE no_payment_due
(
    "name" TEXT default '' not null
        primary key,
    bool TEXT             null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade,
        foreign key (bool) references bool ("name")
            on update cascade on delete cascade
)

CREATE TABLE unemployed
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE `enrolled` (
  `name` TEXT NOT NULL,
  `school` TEXT NOT NULL,
  `month` INTEGER NOT NULL DEFAULT 0,
  PRIMARY KEY (`name`,`school`),
  FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
)

/* Answer the following: How many months did a student in the Air Force miss school the most? Air Force refers to organ = 'air_force'; number of months a student miss school the most refers to MAX(COUNT(month)); */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE bool
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE person
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE disabled
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE enlist
(
    "name"  TEXT not null,
    organ TEXT not null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE filed_for_bankrupcy
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE longest_absense_from_school
(
    "name"  TEXT default '' not null
        primary key,
    "month" INTEGER       default 0  null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE male
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE no_payment_due
(
    "name" TEXT default '' not null
        primary key,
    bool TEXT             null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade,
        foreign key (bool) references bool ("name")
            on update cascade on delete cascade
)

CREATE TABLE unemployed
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE `enrolled` (
  `name` TEXT NOT NULL,
  `school` TEXT NOT NULL,
  `month` INTEGER NOT NULL DEFAULT 0,
  PRIMARY KEY (`name`,`school`),
  FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
)

/* Answer the following: 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? absence of no more than 6 months refers to month < 6; department refers to organ; organ = 'fire_department'; */
SELECT 
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'
/* Given the following database schema: */
CREATE TABLE bool
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE person
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE disabled
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE enlist
(
    "name"  TEXT not null,
    organ TEXT not null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE filed_for_bankrupcy
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE longest_absense_from_school
(
    "name"  TEXT default '' not null
        primary key,
    "month" INTEGER       default 0  null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE male
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE no_payment_due
(
    "name" TEXT default '' not null
        primary key,
    bool TEXT             null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade,
        foreign key (bool) references bool ("name")
            on update cascade on delete cascade
)

CREATE TABLE unemployed
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE `enrolled` (
  `name` TEXT NOT NULL,
  `school` TEXT NOT NULL,
  `month` INTEGER NOT NULL DEFAULT 0,
  PRIMARY KEY (`name`,`school`),
  FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
)

/* Answer the following: How many employed disabled students have zero absences? employed students refers to disabled.name who are NOT in unemployed.name; zero absences refers to month = 0; */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE bool
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE person
(
    "name" TEXT default '' not null
        primary key
)

CREATE TABLE disabled
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE enlist
(
    "name"  TEXT not null,
    organ TEXT not null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE filed_for_bankrupcy
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE longest_absense_from_school
(
    "name"  TEXT default '' not null
        primary key,
    "month" INTEGER       default 0  null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE male
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE no_payment_due
(
    "name" TEXT default '' not null
        primary key,
    bool TEXT             null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade,
        foreign key (bool) references bool ("name")
            on update cascade on delete cascade
)

CREATE TABLE unemployed
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
)

CREATE TABLE `enrolled` (
  `name` TEXT NOT NULL,
  `school` TEXT NOT NULL,
  `month` INTEGER NOT NULL DEFAULT 0,
  PRIMARY KEY (`name`,`school`),
  FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
)

/* Answer the following: Which organization has the highest number of male students? Calculate for the percentage of the male students in the said organization. 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; */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: How many users answered "No" to question 19? Question 19 refer to QuestionID = 19; No refer to AnswerText = 'No' */
SELECT 
SELECT COUNT(QuestionID) FROM Answer WHERE QuestionID = 19 AND AnswerText LIKE 'No'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: From 2016 to 2019, how many users each year were asked the question 13? From 2016 to 2019 refer to SurveyID 2016 BETWEEN 2019; Question 13 refer to QuestionID */
SELECT 
SELECT SurveyID, COUNT(UserID) FROM Answer WHERE QuestionID = 13 AND SurveyID BETWEEN 2016 AND 2019 GROUP BY SurveyID
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: How many users, between the age 27 to 35, were surveyed in 2018? Age 27 to 35 refer to AnswerText 27 BETWEEN 35 where questionid = 1; 2018 refer to SurveyID */
SELECT 
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'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: In 2019, how many users in the United States have a family history of mental illness? 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 */
SELECT 
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'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: Betweeen 2016 to 2019, which year recorded the highest number of people with mental illness? Between 2016 to 2019 refer to SurveyID 2016 BETWEEN 2019; People with mental illness refers to AnswerText = 'Yes' where questionid = 34 */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: How many female users were surveyed in the mental health survey for 2017 in the state of Nebraska? AnswerText = 'Yes' where questiontext = 'Do you have a family history of mental illness?'; AnswerText = 'Female' where questionid = 2; AnswerText = 'Nebraska' where questionid = 4 */
SELECT 
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' )
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: How many users believed that their productivity is ever affected by a mental health issue overall? Users who believed that their productivity is affected by a mental health issues overall refers to AnswerText = 'Yes' where questionid = 54 */
SELECT 
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'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: What are the ages of the oldest and youngest user that were surveyed? Indicate their user id. Oldest user refer to MAX(AnswerText) where questionid = 1; Youngest user refer to MIN(AnswerText) where questionid = 1 */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: 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. Country with least number of users being surveyed refers to MIN(COUNT(AnswerText)) where questionid = 3 */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: What is the average age of the survey respondents in the United States? Average age refer to AVG(AnswerText) where questionid = 1; respondents in the United States refers to AnswerText = 'United States' where questionid = 3 */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: What is the percentage of the the users who would bring up a mental health issue with a potential employer in an interview? Percentage = DIVIDE(SUM(AnswerText = 'Yes' Or AnswerText = 'Maybe'), COUNT(QuestionID = 12))* 100 */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: How many questions in 2014's survey had more than 200 answers? 2014 refer to SurveyID; COUNT(QuestionID) where COUNT(AnswerText) > 200 */
SELECT 
SELECT COUNT(QuestionID) FROM Answer WHERE SurveyID LIKE 2014 GROUP BY QuestionID ORDER BY COUNT(QuestionID) > 200 LIMIT 1
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: What is the oldest age of the users in 2014's survey? what is your age? refer to QuestionText; 2014 refer to SurveyID; oldest age refers to MAX(AnswerText) */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: 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? 2014 refer to SurveyID; Answered No refer to AnswerText = 'No'; Question refer to questiontext */
SELECT 
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'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: 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. 2014 refer to SurveyID; Question refer to questiontext; yes refer to AnswerText = 'Yes' */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: How many users participated in the mental health survey for 2014? mental health survey for 2014 refers to SurveyID = 2014 */
SELECT 
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'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: Please list all the answers to the question "Any additional notes or comments" that are not null in 2014's survey. question refers to questiontext; the answers that are not null refers to AnswerText ! = -1 */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: Please list all the common questions in 2014's survey and 2016's survey. question refers to questiontext; all the common questions in 2014's survey and 2016's survey refers to QuestionID(SurveyID(2014)) = QuestionID(SurveyID(2016)) */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: How many users lived in Canada according to 2018's survey? lived in Canada refers to AnswerText(QuestionID(3)) = 'Canada' */
SELECT 
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'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: Please list all the questions in the mental health survey for 2014. mental health survey for 2014 refers to SurveyID = 2014 */
SELECT 
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
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: According to 2016's survey, what is the number of users with a mental health disorder in the past? users with a mental health disorder in the past refers to AnswerText(QuestionID(32)) = 'Yes' */
SELECT 
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'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: How many users answered "Yes" to the question "Have you had a mental health disorder in the past?" in 3 consecutive years starting from 2016? question refers to questiontext; answered 'Yes' to question refers to AnswerText = 'Yes'; 3 consecutive years starting from 2016 refers to SurveyID = 2016 and SurveyID = 2017 and SurveyID = 2018 */
SELECT 
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'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: What is the average result of the question "What is your age?" in 2014's survey? average result refers to avg(AnswerText(SurveyID = 2014& QuestionID = 1)) */
SELECT 
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?'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: What is the rate of increase of users with a current mental disorder from 2019's survey to 2016's survey? rate of increase = subtract(divide(count(SurveyID = 2019& QuestionID = 33& AnswerText = 'Yes'), count(SurveyID = 2019& QuestionID = 33)), divide(count(SurveyID = 2016& QuestionID = 33& AnswerText = 'Yes'), count(SurveyID = 2016& QuestionID = 33))) */
SELECT 
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.questionid = T2.QuestionID WHERE T2.SurveyID = 2016 AND T1.questiontext LIKE 'Do you currently have a mental health disorder?' AND T2.AnswerText = 'Yes' ) AS REAL) * 100 / ( 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 'Do you currently have a mental health disorder?' AND T2.AnswerText = 'Yes' )
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: Tell the question ID for "Would you bring up a physical health issue with a potential employer in an interview?". */
SELECT 
SELECT questionid FROM Question WHERE questiontext LIKE 'Would you bring up a physical health issue with a potential employer in an interview?'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: How many users answered the question No.20? question No.20 refers to QuestionID = 20 */
SELECT 
SELECT MAX(UserID) - MIN(UserID) + 1 FROM Answer WHERE QuestionID = 20
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: How many questions did user No.5 answer? user No.5 refers to userID = 5 */
SELECT 
SELECT COUNT(QuestionID) FROM Answer WHERE UserID = 5
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: How many users participated in the Survey No.2016? Survey No.2016 refers to SurveyID = 2016 */
SELECT 
SELECT COUNT(DISTINCT UserID) FROM Answer WHERE SurveyID LIKE 2016
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: State the number of questions that were asked in the "mental health survey for 2018". mental health survey for 2018 refers to SurveyID = 2018 */
SELECT 
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'
/* Given the following database schema: */
CREATE TABLE Question
(
    questiontext TEXT,
    questionid   INTEGER
        constraint Question_pk
            primary key
)

CREATE TABLE Survey
(
    SurveyID    INTEGER
        constraint Survey_pk
            primary key,
    Description TEXT
)

CREATE TABLE "Answer"
(
    AnswerText TEXT,
    SurveyID   INTEGER
        constraint Answer_Survey_SurveyID_fk
            references Survey,
    UserID     INTEGER,
    QuestionID INTEGER
        constraint Answer_Question_questionid_fk
            references Question,
    constraint Answer_pk
        primary key (UserID, QuestionID)
)

/* Answer the following: Tell the number of surveys that contained the question “What country do you work in?”. question refers to questiontext */
SELECT 
SELECT COUNT(DISTINCT T1.QuestionID) 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 T2.questiontext = 'What country do you work in?'