Dludora/DAIL-BIRD huggingface dataset:
/* 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 answer did user No. 2681 give to the question "Do you currently have a mental health disorder?"? question refers to questiontext; user No. 2681 refers to UserID = 2681 */
SELECT 
SELECT T1.AnswerText FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questiontext = 'Do you currently have a mental health disorder?' AND T1.UserID = 2681
/* 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: Provide the number of users who took part in the "mental health survey for 2016". mental health survey for 2016 refers to SurveyID = 2016 */
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 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: What was the most common answer for the question "What country do you work in?"? most common answer refers to AnswerText where MAX(COUNT(AnswerText(QuestionID = 3))) */
SELECT 
SELECT T1.AnswerText FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questiontext = 'What country do you work in?' GROUP BY T1.AnswerText ORDER BY COUNT(T1.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 different answers did the question "Describe the conversation you had with your previous employer about your mental health, including their reactions and actions taken to address your mental health issue/questions." get? */
SELECT 
SELECT COUNT(DISTINCT T1.AnswerText) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questiontext LIKE 'Describe the conversation you had with your previous employer about your mental health, including their reactions and actions taken to address your mental health issue/questions.'
/* 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: For the question “What US state or territory do you work in?”, how many people gave "Kansas" as the answer? question refers to questiontext; AnswerText = 'Kansas' */
SELECT 
SELECT COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questiontext LIKE 'What US state or territory do you work in?' AND T1.AnswerText = 'Kansas'
/* 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 people wrote comments for the question "Any additional notes or comments."? question refers to questiontext; wrote comments refers to AnswerText(QuestionID = 103) ! = -1 */
SELECT 
SELECT COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questiontext LIKE 'Any additional notes or comments' AND T1.AnswerText IS NOT NULL
/* 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: For all the users who have been asked "Have you ever been diagnosed with a mental health disorder?", how many of them said "Yes"? have asked refers to questiontext; said 'Yes' refers to AnswerText = 'Yes' */
SELECT 
SELECT COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questiontext LIKE 'Have you ever been diagnosed with a mental health disorder?' AND T1.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: Give the number of users who took the "mental health survey for 2018". mental health survey for 2018 refers to SurveyID = 2018 */
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 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: How many users answered the question "Overall, how much importance does your employer place on physical health?"? question refers to questiontext */
SELECT 
SELECT COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questiontext LIKE 'Overall, how much importance does your employer place on physical health?'
/* 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: For which question did the user No.2183 gave the answer "Mood Disorder (Depression, Bipolar Disorder, etc)"? question refers to questiontext; user No.2183 refers to userID = 2183 */
SELECT 
SELECT T1.AnswerText FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questionid = 2183 AND T1.AnswerText = 'Mood Disorder (Depression, Bipolar Disorder, etc)'
/* 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 was the percentage for the answer of "Yes" was given to the question "Has your employer ever formally discussed mental health (for example, as part of a wellness campaign or other official communication)?"? percentage = divide(count(QuestionID = 15& AnswerText = 'Yes'), count(QuestionID = 15))*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.questiontext LIKE 'Has your employer ever formally discussed mental health (for example, as part of a wellness campaign or other official communication)?'
/* 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 times more for the number of users who took the "mental health survey for 2017" than "mental health survey for 2018"? How many times more = subtract(count(UserID(SurveyID = 2017)), count(UserID(SurveyID = 2018))) */
SELECT 
SELECT CAST(COUNT(T1.UserID) AS REAL) / ( SELECT COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN Survey AS T2 ON T1.SurveyID = T2.SurveyID WHERE T2.Description = 'mental health survey for 2018' ) FROM Answer AS T1 INNER JOIN Survey AS T2 ON T1.SurveyID = T2.SurveyID WHERE T2.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: Among respondents who participated in the survey in 2016, what percentage had a mental health disorder in the past? respondents and 'users' are synonyms; percentage = divide(count(SurveyID = 2016& QuestionID = 32 & AnswerText = 'Yes'), count(SurveyID = 2016& QuestionID = 32))*100% */
SELECT 
SELECT CAST(SUM(CASE WHEN T1.AnswerText LIKE 'Yes' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.SurveyID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T1.QuestionID = 32 AND T1.SurveyID = 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: How many respondents younger than 25 years old did participate in the survey in 2016? respondents' and 'users' are synonyms; younger than 25 years old refers to AnswerText(SurveyID = 2016& QuestionID = 1)< 25 */
SELECT 
SELECT COUNT(DISTINCT T1.UserID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T1.QuestionID = 1 AND T1.SurveyID = 2016 AND T1.AnswerText <= 25
/* 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 number of respondents per survey between 2014 and 2019? respondents and 'users' are synonyms; average number = avg(count(userID(SurveyID = 2014)), count(userID(SurveyID = 2019))) */
SELECT 
SELECT CAST(COUNT(SurveyID) AS REAL) / 5 FROM Answer WHERE SurveyID BETWEEN 2014 AND 2019
/* 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 respondents who participated in the survey in 2019 have ever sought treatment for a mental health disorder from a mental health professional? respondents' and 'users' are synonyms, have ever sought treatment for a mental health disorder from a mental health professional refers to AnswerText(SurveyID = 2019& QuestionID = 7) = 1 */
SELECT 
SELECT COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T1.QuestionID = 7 AND T1.SurveyID = 2019 AND T1.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: How many respondents who participated in the survey in 2014 work remotely at least 50% of the time? respondents' and 'users' are synonyms; work remotely at least 50% of the time refers to AnswerText(SurveyID = 2014& QuestionID = 93) = 'Yes' */
SELECT 
SELECT COUNT(T1.AnswerText) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T1.QuestionID = 93 AND T1.SurveyID = 2014 AND T1.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 questions were asked in the questionary for the mental health survey? */
SELECT 
SELECT COUNT(questiontext) FROM Question
/* 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 respondents of the mental health survey were diagnosed with 'Substance Use Disorder'? respondents' and 'users' are synonyms */
SELECT 
SELECT COUNT(AnswerText) FROM Answer WHERE AnswerText LIKE 'Substance Use Disorder'
/* 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: List the top three popular responses to the question of the survey in 2017 with the question ID no.85. 

survey in 2017 refers to SurveyID = 2017; questionID = 85; MAX(COUNT(AnswerText)) */
SELECT 
SELECT AnswerText FROM Answer WHERE QuestionID = 85 AND SurveyID = 2017 GROUP BY AnswerText ORDER BY COUNT(AnswerText) DESC LIMIT 3
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: How much more total box office gross did the Walt Disney Company have in revenue in 1998 than in 1997? SUBTRACT(SUM(Year = 1998), SUM(Year = 1997)) */
SELECT 
SELECT SUM(CASE WHEN `Year` = 1998 THEN Total ELSE 0 END) - SUM(CASE WHEN `Year` = 1997 THEN Total ELSE 0 END) FROM revenue
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: In which segment did the Walt Disney Company earned a bigger revenue in 1998, Studio Entertainment or Disney Media Networks? Studio Entertainment[NI 1]' > 'Disney Media Networks' where Year = 1998; */
SELECT 
SELECT CASE WHEN 'Studio Entertainment[NI 1]' > 'Disney Media Networks' THEN 'Studio Entertainment[NI 1]' ELSE 'Disney Media Networks' END FROM revenue WHERE `Year` = 1998
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Who is the director of the movie Pinocchio? Pinocchio is the name of the movie; */
SELECT 
SELECT director FROM director WHERE name = 'Pinocchio'
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Please list the villains of all the movies directed by Wolfgang Reitherman. Wolfgang Reitherman refers to director = 'Wolfgang Reitherman'; */
SELECT 
SELECT T2.villian FROM director AS T1 INNER JOIN characters AS T2 ON T1.name = T2.movie_title WHERE T1.director = 'Wolfgang Reitherman' AND T2.villian IS NOT NULL
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Among the movies directed by Wolfgang Reitherman, how many of them were released in December? Wolfgang Reitherman refers to director = 'Wolfgang Reitherman'; released in December refers to (release_date, instr(release_date, '-') + 1, 3) = 'Dec'; */
SELECT 
SELECT COUNT(movie_title) FROM characters AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE SUBSTR(release_date, INSTR(release_date, '-') + 1, 3) = 'Dec' AND T2.director = 'Wolfgang Reitherman'
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: The song "Once Upon a Dream" is associated with the movie directed by whom? directed by whom refers to director; movie refers to movie_title; */
SELECT 
SELECT T2.director FROM characters AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE T1.song = 'Once Upon a Dream'
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Who is the voice actor for the villain of the movie "Alice in Wonderland"? Alice in Wonderland refers to movie_title = 'Alice in Wonderland'; villain refers to character like '%'||T1.villian||'%'; */
SELECT 
SELECT T1.`voice-actor` FROM `voice-actors` AS T1 INNER JOIN characters AS T2 ON T1.movie = T2.movie_title WHERE T1.character LIKE '%' OR T2.villian OR '%' AND T2.movie_title = 'Alice in Wonderland'
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Please list the release dates of all the movies in which Alan Tudyk is a voice actor. FALSE; */
SELECT 
SELECT T2.release_date FROM `voice-actors` AS T1 INNER JOIN characters AS T2 ON T1.movie = T2.movie_title WHERE T1.`voice-actor` = 'Alan Tudyk'
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Among the movies in which Alan Tudyk is a voice actor, how many of them were released after 2012? released after 2012 refers to (release_date, instr(release_date, '-') + 5) > 12; */
SELECT 
SELECT COUNT(T2.movie) FROM characters AS T1 INNER JOIN `voice-actors` AS T2 ON T1.movie_title = T2.movie WHERE T2.`voice-actor` = 'Alan Tudyk' AND SUBSTR(release_date, INSTR(release_date, '-') + 5) > 12
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Among the movies directed by Wolfgang Reitherman, how many of them are Comedies? directed by Wolfgang Reitherman refers to director = 'Wolfgang Reitherman'; comedies refers to genre = 'Comedy'; movies refer to movie_title; */
SELECT 
SELECT COUNT(T3.name) FROM ( SELECT T2.name FROM `movies_total_gross` AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE T2.director = 'Wolfgang Reitherman' AND T1.genre = 'Comedy' GROUP BY T2.name ) T3
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Among the movies directed by Wolfgang Reitherman, which one of them was the most popular? directed by Wolfgang Reitherman refers to director = 'Wolfgang Reitherman'; the most popular movie refers to MAX(total_gross); */
SELECT 
SELECT T2.movie_title FROM director AS T1 INNER JOIN movies_total_gross AS T2 ON T1.name = T2.movie_title WHERE T1.director = 'Wolfgang Reitherman' ORDER BY T2.total_gross DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Please list the movies directed by Wolfgang Reitherman that can be watched by the general audience. directed by Wolfgang Reitherman refers to director = 'Wolfgang Reitherman'; movies refer to movie_title; general audience refers to MPAA_rating = 'G'; */
SELECT 
SELECT T1.movie_title FROM `movies_total_gross` AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE T1.MPAA_rating = 'G' AND T2.director = 'Wolfgang Reitherman'
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Which character is the villain of the most popular movie? the most popular movie refers to movie_title where MAX(total_gross); */
SELECT 
SELECT T2.villian FROM `movies_total_gross` AS T1 INNER JOIN characters AS T2 ON T1.movie_title = T2.movie_title ORDER BY T1.total_gross DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: What is the genre of the movie whose villain is Commander Rourke? FALSE; */
SELECT 
SELECT T2.genre FROM characters AS T1 INNER JOIN movies_total_gross AS T2 ON T2.movie_title = T1.movie_title WHERE T1.villian = 'Commander Rourke'
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Who is the villain of the movie "Beauty and the Beast"? Beauty and the Beast refers to movie_title = 'Beauty and the Beast'; */
SELECT 
SELECT villian FROM characters WHERE movie_title = 'Beauty and the Beast'
/* Given the following database schema: */
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

/* Answer the following: Which movie is the character Robin Hood in? Robin Hood is the main character of the movie which refers to hero = 'Robin Hood'; movie refers to movie_title; */
SELECT 
SELECT movie_title FROM characters WHERE hero = 'Robin Hood'