db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
movies_4
List down the movie titles within the genre of thriller.
genre of thriller refers to genre_name = 'Thriller'
SELECT T1.title FROM movie AS T1 INNER JOIN movie_genres AS T2 ON T1.movie_id = T2.movie_id INNER JOIN genre AS T3 ON T2.genre_id = T3.genre_id WHERE T3.genre_name = 'Thriller'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
What is the location and number of female students in university ID 23 in 2011?
in 2011 refers to year 2011; female students refers to DIVIDE(MULTIPLY(num_students, pct_female_students), 100); location refers to country_name
SELECT T3.country_name, CAST(T2.num_students * T2.pct_female_students AS REAL) / 100 FROM university AS T1 INNER JOIN university_year AS T2 ON T1.id = T2.university_id INNER JOIN country AS T3 ON T3.id = T1.country_id WHERE T2.year = 2011 AND T1.id = 23
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
How many competitors over the age of 30 participated in the 1992 Winter Olympics?
competitors over the age of 30 refer to person_id where age > 30; the 1992 Winter Olympics refers to games_name = '1992 Winter';
SELECT COUNT(T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name = '1992 Winter' AND T2.age > 30
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
Which movie has the keyword 'extremis?'
Which movie refers to title; keyword 'extremis' refers to keyword_name = 'extremis'
SELECT T1.title FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id INNER JOIN keyword AS T3 ON T2.keyword_id = T3.keyword_id WHERE T3.keyword_name = 'extremis'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Give the name of the university with the most number of students in 2015.
most number of students refers to MAX(num_students); in 2015 refers to year = 2015; name of university refers to university_name;
SELECT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2015 ORDER BY T1.num_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
State the name of the city that held game id 3.
name of city refers to city_name
SELECT T2.city_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id WHERE T1.games_id = 3
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
university
Calculate the average score of Emory University from 2011 to 2016.
average score refers to avg(score); Emory University refers to university_name = 'Emory University'; from 2011 to 2016 refers to year BETWEEN 2011 AND 2016;
SELECT AVG(T1.score) FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'Emory University' AND T1.year BETWEEN 2011 AND 2016
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
What is the average age of Argentina's athletes who participated in the Summer Olympics in 2012?
AVG(age) where games_name = '2012 Summer' and region_name = 'Argentina';
SELECT AVG(T2.age) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person_region AS T3 ON T2.person_id = T3.person_id INNER JOIN noc_region AS T4 ON T3.region_id = T4.id WHERE T1.games_name = '2012 Summer' AND T4.region_name = 'Argentina'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
State the genre of the movie title with a runtime of only 14 minutes.
genre refers to genre_name; runtime of only 14 minutes refers to runtime = 14
SELECT T3.genre_name FROM movie AS T1 INNER JOIN movie_genres AS T2 ON T1.movie_id = T2.movie_id INNER JOIN genre AS T3 ON T2.genre_id = T3.genre_id WHERE T1.runtime = 14
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
In what year does the Brown University score the highest?
Brown University refers to university_name = 'Brown University'; score the highest refers to MAX(score)
SELECT T1.year FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'Brown University' ORDER BY T1.score DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
In Barcelona, how many Olympic games were held?
Barcelona refers to city_name = 'Barcelona';
SELECT COUNT(T1.games_id) FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id WHERE T2.city_name = 'Barcelona'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
Among the zero-budget movie titles, which one has made the highest revenue?
zero-budget refers to budget = 0; highest revenue refers to max(revenue)
SELECT title FROM movie WHERE budget = 0 ORDER BY revenue DESC LIMIT 1
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Give the names of universities with number of students ranges from 400 to 1000.
number of students ranges from 400 to 1000 refers to num_students BETWEEN 400 AND 1000; name of university refers to university_name
SELECT DISTINCT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.num_students BETWEEN 400 AND 1000
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
List the name of competitors from Argentina.
name refers to full_name; Argentina refers to region_name = 'Argentina';
SELECT T3.full_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Argentina'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
Tell the language of the movie "C'era una volta il West".
language refers to language_name; movie "C'era una volta il West" refers to title = 'C''era una volta il West'
SELECT T3.language_name FROM movie AS T1 INNER JOIN movie_languages AS T2 ON T1.movie_id = T2.movie_id INNER JOIN language AS T3 ON T2.language_id = T3.language_id WHERE T1.title LIKE 'C%era una volta il West'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
In which country does Johns Hopkins University located?
Johns Hopkins University refers to university_name = 'Johns Hopkins University'; which country refers to country_name
SELECT T2.country_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T1.university_name = 'Johns Hopkins University'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
movies_4
Accumulate the budget of the movie titles with the keyword of "video game".
keyword of "video game" refers to keyword_name = 'video game'
SELECT SUM(T1.budget) FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id INNER JOIN keyword AS T3 ON T2.keyword_id = T3.keyword_id WHERE T3.keyword_name = 'video game'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Calculate number of male students in Emory University in 2011.
in 2011 refers to year 2011; number of male students refers to SUBTRACT(num_students, DIVIDE(MULTIPLY(num_students, pct_male_students), 100)); in Emory University refers to university_name = 'Emory University'
SELECT CAST((T1.num_students - (T1.num_students * T1.pct_female_students)) AS REAL) / 100 FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'Emory University' AND T1.year = 2011
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
List out the name of the game that the people participated in games id 13.
name of games refers to games_name;
SELECT DISTINCT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T2.games_id = 13
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
Write down the release date of the movies produced by Twentieth Century Fox Film Corporation.
produced by Twentieth Century Fox Film Corporation refers to company_name = 'Twentieth Century Fox Film Corporation'
SELECT T3.release_date FROM production_company AS T1 INNER JOIN movie_company AS T2 ON T1.company_id = T2.company_id INNER JOIN movie AS T3 ON T2.movie_id = T3.movie_id WHERE T1.company_name = 'Twentieth Century Fox Film Corporation'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
List the countries of universities that scored 70 and below in 2016.
scored 70 and below refers to score < 70; in 2016 refers to year = 2016
SELECT DISTINCT T3.country_name FROM university AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.university_id INNER JOIN country AS T3 ON T3.id = T1.country_id WHERE T2.score < 70 AND T2.year = 2016
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
List the name of the games that Georgios Abaris participated.
name of games refers to games_name;
SELECT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'Georgios Abaris'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
Which actor plays Optimus Prime?
Which actor refers to person_name; Optimus Prime refers to character_name = 'Optimus Prime (voice)'
SELECT DISTINCT T1.person_name FROM person AS T1 INNER JOIN movie_cast AS T2 ON T1.person_id = T2.person_id WHERE T2.character_name = 'Optimus Prime (voice)'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Provide the name of the university with the highest number of male students.
highest number of female students refers to MAX(SUBTRACT(num_students, DIVIDE(MULTIPLY(num_students, pct_female_students), 100))); name of university refers to university_name
SELECT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id ORDER BY T1.num_students * T1.pct_female_students / 100 - T1.num_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
What is the name of the Olympic game with the most competitors held in Barcelona?
Barcelona refers to city_name = 'Barcelona'; the most competitors refer to MAX(COUNT(games_name)); name of game refers to games_name;
SELECT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN games_city AS T3 ON T2.games_id = T3.games_id INNER JOIN city AS T4 ON T3.city_id = T4.id WHERE T4.city_name = 'Barcelona' GROUP BY T1.id ORDER BY COUNT(T2.person_id) DESC LIMIT 1
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
What is the genre of the movie title with the lowest revenue generated?
genre refers to genre_name; lowest revenue refers to min(revenue)
SELECT T3.genre_name FROM movie AS T1 INNER JOIN movie_genres AS T2 ON T1.movie_id = T2.movie_id INNER JOIN genre AS T3 ON T2.genre_id = T3.genre_id ORDER BY T1.revenue LIMIT 1
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
How many universities are located in Japan?
located in Japan refers to country_name = 'Japan';
SELECT COUNT(*) FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Japan'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
How many female students are there in University of Pennsylvania in 2011?
in 2011 refers to year 2011; female students refers to DIVIDE(MULTIPLY(num_students, pct_female_students), 100); University of Pennsylvania refers to a university name;
SELECT CAST(T1.num_students * T1.pct_female_students AS REAL) / 100 FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2011 AND T2.university_name = 'University of Pennsylvania'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
Calculate the average age of the competitors who participated in the 1924 Winter.
AVG(age) where games_name = '1924 Winter';
SELECT AVG(T2.age) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name = '1924 Winter'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
Are there any post-production movies in Nederlands?
post-production movies refers to movie_status = 'Post Production'; Nederlands refers to language_name = 'Nederlands';
SELECT DISTINCT CASE WHEN T1.movie_status = 'Post Production' THEN 'YES' ELSE 'NO' END AS YORN FROM movie AS T1 INNER JOIN movie_languages AS T2 ON T1.movie_id = T2.movie_id INNER JOIN language AS T3 ON T2.language_id = T3.language_id WHERE T3.language_name = 'Nederlands'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Give the name and score of the university ID 124.
name of university refers to university_name;
SELECT T2.university_name, T1.score FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.id = 124
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
Calculate the percentage of bronze medals won by men's basketball players.
DIVIDE(COUNT(competitor_id where medal_name = 'Bronze'), COUNT(competitor_id)) as percentage where event_name = 'Basketball Men''s Basketball';
SELECT CAST(COUNT(CASE WHEN T4.medal_name = 'Bronze' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.person_id) FROM competitor_event AS T1 INNER JOIN games_competitor AS T2 ON T1.competitor_id = T2.id INNER JOIN event AS T3 ON T1.event_id = T3.id INNER JOIN medal AS T4 ON T1.medal_id = T4.id WHERE T3.event_name LIKE 'Basketball Men%s Basketball'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
Provide the genre of a movie title with a tagline of "A long time ago in a galaxy far, far away…".
genre refers to genre_name; tagline of "A long time ago in a galaxy far, far away…" refers to tagline = 'A long time ago in a galaxy far, far away…'
SELECT T3.genre_name FROM movie AS T1 INNER JOIN movie_genres AS T2 ON T1.movie_id = T2.movie_id INNER JOIN genre AS T3 ON T3.genre_id = T2.genre_id WHERE T1.tagline = 'A long time ago in a galaxy far, far away...'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
What is the total number of ranking criteria under the ranking system called Shanghai Ranking?
ranking system called Shanghai Ranking refers to system_name = 'Shanghai Ranking';
SELECT COUNT(*) FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id WHERE T1.system_name = 'Shanghai Ranking'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
Provide the name of competitors from Greece.
name refers to full_name; Greece refers to region_name = 'Greece';
SELECT T3.full_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Greece'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
Provide the homepage of the Bahasa Indonesia movies.
Bahasa Indonesia movies refers to language_name = 'Bahasa indonesia'
SELECT DISTINCT T1.homepage FROM movie AS T1 INNER JOIN movie_languages AS T2 ON T1.movie_id = T2.movie_id INNER JOIN language AS T3 ON T2.language_id = T3.language_id WHERE T3.language_name = 'Bahasa indonesia'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Provide the university name and ID of the university found in Turkey.
found in Turkey refers to country_name = 'Turkey';
SELECT T1.university_name, T1.id FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Turkey'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
List the names of the games held in Paris.
Paris refers to city_name = 'Paris'; names of games refers to games_name;
SELECT T3.games_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T2.city_name = 'Paris'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
What is the percentage of romance films among films produced in India in 2015?
romance films refers to genre_name = 'Romance'; in India refers to country_name = 'India'; 2015 refers to release_date BETWEEN '2015-01-01' AND '2015-01-31'; percentage = divide(sum(movie_id) when genre_name = 'Romance', count(movie_id)) as percentage
SELECT CAST(COUNT(CASE WHEN T4.genre_name = 'Romance' THEN T1.movie_id ELSE NULL END) AS REAL) * 100 / COUNT(T1.movie_id) FROM movie AS T1 INNER JOIN movie_genres AS T2 ON T1.movie_id = T2.movie_id INNER JOIN production_COUNTry AS T3 ON T1.movie_id = T3.movie_id INNER JOIN genre AS T4 ON T2.genre_id = T4.genre_id INNER JOIN COUNTry AS T5 ON T3.COUNTry_id = T5.COUNTry_id WHERE T5.COUNTry_name = 'India' AND T1.release_date BETWEEN '2015-01-01' AND '2015-12-31'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Give the criteria name where Harvard University scored 100.
Harvard University refers to university_name = 'Harvard University'; scored 100 refers to score = 100
SELECT DISTINCT T3.criteria_name FROM university AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.university_id INNER JOIN ranking_criteria AS T3 ON T3.id = T2.ranking_criteria_id WHERE T1.university_name = 'Harvard University' AND T2.score = 100
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
What is the average age of the people who participated in the winter season?
AVG(age) where season = 'Winter';
SELECT AVG(T2.age) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.season = 'Winter'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
List 10 crews alongside their jobs who worked on the movie 'Mad Max: Fury Road.'
crews refers to person_name; movie 'Mad Max: Fury Road' refers to title = 'Mad Max: Fury Road'
SELECT T3.person_name FROM movie AS T1 INNER JOIN movie_crew AS T2 ON T1.movie_id = T2.movie_id INNER JOIN person AS T3 ON T2.person_id = T3.person_id WHERE T1.title = 'Mad Max: Fury Road' LIMIT 10
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Provide the score of the most populated university in 2011.
most populated university refers to MAX(num_students); in 2011 refers to year = 2011;
SELECT T2.score FROM university_year AS T1 INNER JOIN university_ranking_year AS T2 ON T1.university_id = T2.university_id WHERE T1.year = 2011 ORDER BY T1.num_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Give the student staff ratio of university ID 35.
null
SELECT student_staff_ratio FROM university_year WHERE university_id = 35
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
What is the name of the youngest competitor?
name refers to full_name; the youngest refers to MIN(age);
SELECT T1.full_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id ORDER BY T2.age LIMIT 1
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
List down the movie titles that were produced in Canada.
produced in Canada refers to country_name = 'Canada'
SELECT T1.title FROM movie AS T1 INNER JOIN production_COUNTry AS T2 ON T1.movie_id = T2.movie_id INNER JOIN COUNTry AS T3 ON T2.COUNTry_id = T3.COUNTry_id WHERE T3.COUNTry_name = 'Canada'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Calculate the average score of university ID 79 between year 2013 to 2015.
average score refers to avg(score); between year 2013 to 2015 refers to year BETWEEN 2013 AND 2015
SELECT AVG(score) FROM university_ranking_year WHERE year BETWEEN 2013 AND 2015 AND university_id = 79
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
What is the NOC code of the region of the competitors weighted 77 kg?
NOC code refers to noc; competitors weighted 77 kg refer to person_id where weight = 77;
SELECT T1.noc FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.weight = 77
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
university
List down all universities that scored below 50.
scored below 50 refers to score < 50; all universities refers to university_name;
SELECT DISTINCT T2.university_name FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.score < 50
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
movies_4
Calculate the revenues made by Fantasy Films and Live Entertainment.
made by Fantasy Films refers to company_name = 'Fantasy Films'; Live Entertainment refers to company_name = 'Live Entertainment'
SELECT SUM(T3.revenue) FROM production_company AS T1 INNER JOIN movie_company AS T2 ON T1.company_id = T2.company_id INNER JOIN movie AS T3 ON T2.movie_id = T3.movie_id WHERE T1.company_name IN ('Fantasy Films', 'Live Entertainment')
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
In years 2011 to 2013, what is the total number of female students in university ID 40?
total number of female students refers to SUM(DIVIDE(MULTIPLY(pct_female_students, num_students), 100)); In years 2011 to 2013 refers to year BETWEEN 2011 AND 2013
SELECT SUM(CAST(num_students * pct_female_students AS REAL) / 100) FROM university_year WHERE year BETWEEN 2011 AND 2013 AND university_id = 40
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
In which city was the game held where the oldest competitor participated?
in which city refers to city_name; the oldest refers to MAX(age);
SELECT T4.city_name FROM games_competitor AS T1 INNER JOIN games AS T2 ON T1.games_id = T2.id INNER JOIN games_city AS T3 ON T1.games_id = T3.games_id INNER JOIN city AS T4 ON T3.city_id = T4.id ORDER BY T1.age DESC LIMIT 1
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
The movie 'Gojira ni-sen mireniamu' is from which country?
movie 'Gojira ni-sen mireniamu' refers to title = 'Gojira ni-sen mireniamu'; which country refers to country_name
SELECT T3.COUNTry_name FROM movie AS T1 INNER JOIN production_COUNTry AS T2 ON T1.movie_id = T2.movie_id INNER JOIN COUNTry AS T3 ON T2.COUNTry_id = T3.COUNTry_id WHERE T1.title = 'Gojira ni-sen mireniamu'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
What is the average score of all universities in 2012?
average score refers to avg(score); in 2012 refers to year = 2012
SELECT AVG(score) FROM university_ranking_year WHERE year = 2012
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
What is the percentage of people whose age greater than 24 and participate in winter season?
DIVIDE(COUNT(season = 'Winter' and age > 24), COUNT(person_id)) as percentage;
SELECT CAST(COUNT(CASE WHEN T2.age > 24 AND T1.season = 'Winter' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.games_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
What is the country ID of the movie with the title of "Pirates of the Caribbean: Dead Man's Chest"?
title of "Pirates of the Caribbean: Dead Man's Chest" refers to title = 'Pirates of the Caribbean: Dead Man''s Chest'
SELECT T2.COUNTry_id FROM movie AS T1 INNER JOIN production_COUNTry AS T2 ON T1.movie_id = T2.movie_id WHERE T1.title LIKE 'Pirates of the Caribbean: Dead Man%s Chest'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Provide the criteria name of the ranking criteria ID 13.
null
SELECT criteria_name FROM ranking_criteria WHERE id = 13
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
Give the NOC code and region name of the heaviest competitor.
NOC code refers to noc; the heaviest refers to MAX(weight);
SELECT T1.noc, T1.region_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id ORDER BY T3.weight DESC LIMIT 1
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
What is the average revenue of American movies in 2006?
American movies refers to country_name = 'United States of America'; in 2006 refers to release_date LIKE '2006%'; average revenue = AVG(revenue)
SELECT AVG(T1.revenue) FROM movie AS T1 INNER JOIN production_COUNTry AS T2 ON T1.movie_id = T2.movie_id INNER JOIN COUNTry AS T3 ON T2.COUNTry_id = T3.COUNTry_id WHERE T3.COUNTry_name = 'United States of America' AND CAST(STRFTIME('%Y', T1.release_date) AS INT) = 2006
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
What is the ID of university with the largest percentage of international students?
largest percentage of international students refers to MAX(pct_international_students); ID of university refers to university_id
SELECT university_id FROM university_year ORDER BY pct_international_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
movies_4
List down the tagline of the Polski movies.
Polski movies refers to language_name = 'Polski'
SELECT DISTINCT T1.tagline FROM movie AS T1 INNER JOIN movie_languages AS T2 ON T1.movie_id = T2.movie_id INNER JOIN language AS T3 ON T2.language_id = T3.language_id WHERE T3.language_name = 'Polski'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Provide the country ID of Cyprus.
Cyprus refers to country_name = 'Cyprus';
SELECT id FROM country WHERE country_name = 'Cyprus'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
Provide the competitors' names who joined the 2000 Summer.
the competitors' names refer to full_name; the 2000 Summer refers to games_name = '2000 Summer';
SELECT T3.full_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.games_name = '2000 Summer'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
What is the genre of the movie title which was well-received by the audiences but made the lowest revenue?
genre refers to genre_name; well-received by the audiences refers to max(vote_average); lowest revenue refers to min(revenue)
SELECT T3.genre_name FROM movie AS T1 INNER JOIN movie_genres AS T2 ON T1.movie_id = T2.movie_id INNER JOIN genre AS T3 ON T2.genre_id = T3.genre_id ORDER BY T1.vote_average DESC, T1.revenue LIMIT 1
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
What is the score of university ID 68 in 2015?
in 2015 refers to year = 2015
SELECT score FROM university_ranking_year WHERE year = 2015 AND university_id = 68
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
In which city the 2004 Summer was held?
in which city refers to city_name; the 2004 Summer refers to games_name = '2004 Summer';
SELECT T2.city_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T3.games_name = '2004 Summer'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
List the title of movies in Latin released between 1/01/1990 and 12/31/1995.
movies in Latin refers to language_name = 'Latin'; released between 1/01/1990 and 12/31/1995 refers to release_date BETWEEN '1990-01-01' AND '1995-12-31'
SELECT T1.title FROM movie AS T1 INNER JOIN movie_languages AS T2 ON T1.movie_id = T2.movie_id INNER JOIN language AS T3 ON T2.language_id = T3.language_id WHERE T3.language_name = 'Latin' AND T1.release_date BETWEEN '1990-01-01' AND '1995-12-31'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Calculate the average number of students of all universities in 2012.
average number of students refers to avg(num_students); in 2012 refers to year = 2012
SELECT AVG(num_students) FROM university_year WHERE year = 2012
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
List down the games ID of games held in Tokyo.
Tokyo refers to city_name = 'Tokyo';
SELECT T1.games_id FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id WHERE T2.city_name = 'Tokyo'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
Work out the difference in revenues made between the English and Latin movies.
English refers to language_name = 'English'; Latin refers to language_name = 'Latin'; difference in revenues = subtract(sum(movie_id) when language_name = 'English', sum(movie_id) when language_name = 'Latin')
SELECT SUM(CASE WHEN T3.language_name = 'English' THEN T1.revenue ELSE 0 END) - SUM(CASE WHEN T3.language_name = 'Latin' THEN T1.revenue ELSE 0 END) AS DIFFERENCE FROM movie AS T1 INNER JOIN movie_languages AS T2 ON T1.movie_id = T2.movie_id INNER JOIN language AS T3 ON T2.language_id = T3.language_id
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
university
Calculate the average number of criterias among "Times Higher Education World University Ranking","Shanghai Ranking" and "Center for World University Rankings".
average number of criterias refers to DIVIDE(SUM(id), 3); "Times Higher Education World University Ranking", "Shanghai Ranking" and "Center for World University Rankings" refers to system_name IN ('Times Higher Education World University Ranking', 'Shanghai Ranking', 'Center for World University Rankings');
SELECT (SUM(CASE WHEN T1.system_name = 'Center for World University Rankings' THEN 1 ELSE 0 END) + SUM(CASE WHEN T1.system_name = 'Shanghai Ranking' THEN 1 ELSE 0 END) + SUM(CASE WHEN T1.system_name = 'Times Higher Education World University Ranking' THEN 1 ELSE 0 END)) / 3 FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
What is the average weight of the competitors who won a silver medal?
AVG(weight) where medal_name = 'Silver';
SELECT AVG(T1.weight) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN competitor_event AS T3 ON T2.id = T3.competitor_id INNER JOIN medal AS T4 ON T3.medal_id = T4.id WHERE T4.medal_name = 'Silver'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
university
How many times more was the number of students of University of Ottawa than Joseph Fourier University in 2013?
Joseph Fourier University refers to university_name = 'Joseph Fourier University'; University of Ottawa refers to university_name = 'University of Ottawa'; in 2013 refers to year = 2013; how many times more refers to DIVIDE(SUM(num_students where university_name = 'University of Ottawa'), SUM(num_students where university_name = 'Joseph Fourier University'))
SELECT CAST(SUM(CASE WHEN T2.university_name = 'University of Ottawa' THEN T1.num_students ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.university_name = 'Joseph Fourier University' THEN T1.num_students ELSE 0 END) FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2013
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
olympics
What is the sport name of "Cross Country Skiing Men's 10/15 kilometres Pursuit" event?
"Cross Country Skiing Men's 10/15 kilometres Pursuit" refers to event_name = 'Cross Country Skiing Men''s 10/15 kilometres Pursuit';
SELECT T1.sport_name FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id WHERE T2.event_name LIKE 'Cross Country Skiing Men%s 10/15 kilometres Pursuit'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
List 10 movie titles that were produced in France.
France refers to country_name = 'France'
SELECT T1.title FROM movie AS T1 INNER JOIN production_COUNTry AS T2 ON T1.movie_id = T2.movie_id INNER JOIN COUNTry AS T3 ON T2.COUNTry_id = T3.COUNTry_id WHERE T3.COUNTry_name = 'France' LIMIT 10
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
movies_4
How many Indian movies between 1/2/1990 and 12/30/2003 have revenue of more than 75,000,000 and popularity of no less than 20?
Indian movies refers to country_name = 'India'; between 1/2/1990 and 12/30/2003 refers to release_date BETWEEN '1990-01-02' AND '2003-12-30'; revenue of more than 75,000,000 refers to revenue > 75000000; popularity of no less than 20 refers to popularity > = 20
SELECT COUNT(T2.movie_id) FROM movie AS T1 INNER JOIN production_COUNTry AS T2 ON T1.movie_id = T2.movie_id WHERE T1.revenue > 75000000 AND T1.popularity >= 20 AND T1.release_date BETWEEN '1990-01-01' AND '2003-12-31'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
olympics
Provide the names of competitors who received a gold medal.
names of competitors refer to full_name; gold medal refers to medal_name = 'Gold';
SELECT DISTINCT T1.full_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN competitor_event AS T3 ON T2.id = T3.competitor_id INNER JOIN medal AS T4 ON T3.medal_id = T4.id WHERE T4.medal_name = 'Gold'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
What is the iso code of "Kyrgyz Republic"?
iso code refers to country_iso_code; "Kyrgyz Republic" refers to country_name = 'Kyrgyz Republic'
SELECT COUNTry_iso_code FROM COUNTry WHERE COUNTry_name = 'Kyrgyz Republic'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
olympics
In what year and season did Sohail Abbas compete?
year refers to games_year;
SELECT T1.games_year, T1.season FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'Sohail Abbas'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
For movies with the keyword of "civil war", calculate the average revenue generated by these movies.
keyword of "civil war" refers to keyword_name = 'civil war'; average revenue = AVG(revenue)
SELECT AVG(T1.revenue) FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id INNER JOIN keyword AS T3 ON T2.keyword_id = T3.keyword_id WHERE T3.keyword_name = 'civil war'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
olympics
Provide the age of the tallest competitor.
the tallest refers to MAX(height);
SELECT T2.age FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id ORDER BY T1.height DESC LIMIT 1
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
How many movies were produced by "Eddie Murphy Productions"?
produced by "Eddie Murphy Productions" refers to company_name = 'Eddie Murphy Productions'
SELECT COUNT(T1.movie_id) FROM movie_company AS T1 INNER JOIN production_company AS T2 ON T1.company_id = T2.company_id WHERE T2.company_name = 'Eddie Murphy Productions'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
movies_4
What is the longest runtime of all movies?
longest runtime refers to max(runtime)
SELECT MAX(runtime) FROM movie
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
olympics
What is the season of the game where a competitor who weighted 73 kg and 180 cm tall, participated?
competitor who weighted 73 kg and 180 cm tall refers to person_id where height = 180 and weight = 73;
SELECT DISTINCT T1.season FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.height = 180 AND T3.weight = 73
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
What is the most common keyword among all the movies released in 2006?
most common keyword refers to max(count(keyword_name)); movies released in 2006 refers to release_date LIKE '%2006%'
SELECT T3.keyword_name FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id INNER JOIN keyword AS T3 ON T2.keyword_id = T3.keyword_id WHERE T1.release_date LIKE '2006%' GROUP BY T3.keyword_name ORDER BY COUNT(T3.keyword_name) DESC LIMIT 1
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
movies_4
Provide the overview for the movie "The Pacifier".
movie "The Pacifier" refers to title = 'The Pacifier'
SELECT overview FROM movie WHERE title = 'The Pacifier'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
olympics
How many female competitors were from Iran?
female competitors refer to person_id where gender = 'F'; from Iran refers to region_name = 'Iran';
SELECT COUNT(T2.person_id) FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Iran' AND T3.gender = 'F'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
List all the actors who have played characters with "captain" in their names.
List all the actors refers to person_name; characters with "captain" in their names refers to character_name LIKE '%captain%';
SELECT DISTINCT T1.person_name FROM person AS T1 INNER JOIN movie_cast AS T2 ON T1.person_id = T2.person_id WHERE T2.character_name LIKE '%captain%'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
movies_4
Find out the popularity of the movies with the highest vote count.
highest vote count refers to max(vote_count)
SELECT popularity FROM movie ORDER BY vote_COUNT DESC LIMIT 1
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
olympics
List out the id of event that achieve the gold medal.
the gold medal refers to medal_name = 'Gold';
SELECT T2.event_id FROM medal AS T1 INNER JOIN competitor_event AS T2 ON T1.id = T2.medal_id WHERE T1.medal_name = 'Gold'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
olympics
In the 2014 Winter game, what is the percentage of competitors who age 28 years old?
DIVIDE(COUNT(age = 28), COUNT(id)) as percentage where games_name = '2014 Winter';
SELECT CAST(COUNT(CASE WHEN T2.age = 28 THEN 1 END) AS REAL) * 100 / COUNT(T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name = '2014 Winter'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
What is the language ID of the movie "Walk the Line"?
movie "Walk the Line" refers to title = 'Walk the Line'
SELECT T2.language_id FROM movie AS T1 INNER JOIN movie_languages AS T2 ON T1.movie_id = T2.movie_id WHERE T1.title = 'Walk the Line'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
olympics
Compute the average height of competitors whose age ranges from 22 to 28.
AVG(height) where age BETWEEN 22 AND 28;
SELECT AVG(T1.height) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T2.age BETWEEN 22 AND 28
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
Who is the director for the movie 'Transformers?'
the director refers to person_name where job = 'Director'; movie 'Transformers' refers to title = 'Transformers'
SELECT T3.person_name FROM movie AS T1 INNER JOIN movie_crew AS T2 ON T1.movie_id = T2.movie_id INNER JOIN person AS T3 ON T2.person_id = T3.person_id WHERE T1.title = 'Transformers' AND T2.job = 'Director'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
address
Which residential area in Arecibo county has the highest average house value? Please give its zip_code.
"ARECIBO" is the county; highest average house value refers to Max(avg_house_value)
SELECT T1.zip_code FROM zip_data AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code WHERE T2.county = 'ARECIBO' ORDER BY T1.avg_house_value DESC LIMIT 1
CREATE TABLE state ( name TEXT, -- abbreviation TEXT primary key, ); CREATE TABLE country ( zip_code INTEGER, -- foreign key (state) references state(abbreviation), county TEXT, -- primary key (zip_code, county), state TEXT, -- foreign key (zip_code) references zip_data(zip_code), ); CREATE TABLE area_code ( primary key (zip_code, area_code), zip_code INTEGER, -- area_code INTEGER, -- foreign key (zip_code) references zip_data(zip_code), ); CREATE TABLE congress ( House TEXT, -- Example Values: `House of Repsentatives`, `Senate` | Value Statics: Total count 540 - Distinct count 2 - Null count 0 District INTEGER, -- land_area REAL, -- party TEXT, -- Example Values: `Republican`, `Democrat`, `Independent` | Value Statics: Total count 540 - Distinct count 3 - Null count 0 abbreviation TEXT, -- state TEXT, -- cognress_rep_id TEXT primary key, CID TEXT, -- foreign key (abbreviation) references state(abbreviation), first_name TEXT, -- last_name TEXT, -- ); CREATE TABLE avoid ( primary key (zip_code, bad_alias), bad_alias TEXT, -- foreign key (zip_code) references zip_data(zip_code), zip_code INTEGER, -- ); CREATE TABLE zip_data ( population_2010 INTEGER, -- "1st_quarter_payroll" INTEGER, -- residential_mailboxes INTEGER, -- american_indian_population INTEGER, -- spouses INTEGER, -- over_65 INTEGER, -- employees INTEGER, -- white_population INTEGER, -- multi_county TEXT, -- Example Values: `No`, `Yes` | Value Statics: Total count 41563 - Distinct count 2 - Null count 0 businesses INTEGER, -- black_population INTEGER, -- avg_house_value INTEGER, -- children INTEGER, -- foreign key (state) references state(abbreviation), single_family_delivery_units INTEGER, -- time_zone TEXT, -- Example Values: `Eastern`, `Atlantic`, `Central`, `Mountain`, `Pacific` | Value Statics: Total count 40955 - Distinct count 12 - Null count 608 parents_and_widowed INTEGER, -- state_fips INTEGER, -- monthly_benefits_all INTEGER, -- male_population INTEGER, -- type TEXT, -- Example Values: `Unique Post Office`, `Post Office`, `P.O. Box Only`, `Branch`, `Non Postal Community Name` | Value Statics: Total count 41563 - Distinct count 9 - Null count 0 population_2020 INTEGER, -- other_population INTEGER, -- avg_income_per_household INTEGER, -- daylight_savings TEXT, -- Example Values: `Yes`, `No` | Value Statics: Total count 41563 - Distinct count 2 - Null count 0 female_median_age REAL, -- annual_payroll INTEGER, -- female_population INTEGER, -- persons_per_household REAL, -- division TEXT, -- Example Values: `Middle Atlantic`, `New England`, `South Atlantic`, `East South Central`, `East North Central` | Value Statics: Total count 40725 - Distinct count 9 - Null count 838 city TEXT, -- total_delivery_receptacles INTEGER, -- organization TEXT, -- state TEXT, -- monthly_benefits_retired_workers INTEGER, -- foreign key (CBSA) references CBSA(CBSA), asian_population INTEGER, -- hispanic_population INTEGER, -- male_median_age REAL, -- region TEXT, -- Example Values: `Northeast`, `South`, `Midwest`, `West` | Value Statics: Total count 40725 - Distinct count 4 - Null count 838 county_fips INTEGER, -- median_age REAL, -- retired_workers INTEGER, -- total_beneficiaries INTEGER, -- latitude REAL, -- households INTEGER, -- hawaiian_population INTEGER, -- monthly_benefits_widowed INTEGER, -- water_area REAL, -- business_mailboxes INTEGER, -- longitude REAL, -- multi_family_delivery_units INTEGER, -- CBSA INTEGER, -- zip_code INTEGER primary key, elevation INTEGER, -- land_area REAL, -- disabled_workers INTEGER, -- ); CREATE TABLE alias ( foreign key (zip_code) references zip_data(zip_code), alias TEXT, -- zip_code INTEGER primary key, ); CREATE TABLE zip_congress ( district TEXT, -- foreign key (district) references congress(cognress_rep_id), primary key (zip_code, district), foreign key (zip_code) references zip_data(zip_code), zip_code INTEGER, -- ); CREATE TABLE CBSA ( CBSA_type TEXT, -- Example Values: `Micro`, `Metro` | Value Statics: Total count 465 - Distinct count 2 - Null count 0 CBSA INTEGER primary key, CBSA_name TEXT, -- );
movies_4
Write all the keywords belonging to the movie 'Sky Captain and the World of Tomorrow.'
keywords refers to keyword_name; movie 'Sky Captain and the World of Tomorrow' refers to title = 'Sky Captain and the World of Tomorrow'
SELECT T3.keyword_name FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id INNER JOIN keyword AS T3 ON T2.keyword_id = T3.keyword_id WHERE T1.title = 'Sky Captain and the World of Tomorrow'
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
movies_4
Find out the language ID of the movie with the highest popularity.
highest popularity refers to max(popularity)
SELECT T2.language_id FROM movie AS T1 INNER JOIN movie_languages AS T2 ON T1.movie_id = T2.movie_id ORDER BY T1.popularity DESC LIMIT 1
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
olympics
Among the competitors with age ranges 24 and below, calculate the difference between the number of competitors who weighed greater than 70 kg and competitors who weighted less than 70 kg.
SUBTRACT(COUNT(weight > 70), COUNT(weight < 70)) where age < 24;
SELECT COUNT(CASE WHEN T1.weight > 70 THEN 1 ELSE NULL END) - COUNT(CASE WHEN T1.weight < 70 THEN 1 ELSE NULL END) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T2.age < 24
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
movies_4
What is the third least common genre?
least common genre refers to min(count(genre_name))
SELECT T2.genre_name FROM movie_genres AS T1 INNER JOIN genre AS T2 ON T1.genre_id = T2.genre_id GROUP BY T2.genre_id ORDER BY COUNT(T1.movie_id) LIMIT 2, 1
CREATE TABLE production_company ( company_name TEXT default NULL, -- company_id INTEGER not null primary key, ); CREATE TABLE gender ( gender TEXT default NULL, -- Example Values: `Unspecified`, `Female`, `Male` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 gender_id INTEGER not null primary key, ); CREATE TABLE movie_genres ( foreign key (movie_id) references movie(movie_id), movie_id INTEGER default NULL, -- genre_id INTEGER default NULL, -- foreign key (genre_id) references genre(genre_id), ); CREATE TABLE movie ( budget INTEGER default NULL, -- popularity REAL default NULL, -- movie_status TEXT default NULL, -- Example Values: `Released`, `Rumored`, `Post Production` | Value Statics: Total count 4627 - Distinct count 3 - Null count 0 runtime INTEGER default NULL, -- tagline TEXT default NULL, -- revenue INTEGER default NULL, -- overview TEXT default NULL, -- vote_count INTEGER default NULL, -- vote_average REAL default NULL, -- release_date DATE default NULL, -- homepage TEXT default NULL, -- title TEXT default NULL, -- movie_id INTEGER not null primary key, ); CREATE TABLE movie_languages ( foreign key (language_role_id) references language_role(role_id), foreign key (language_role_id) references language_role(role_id), language_role_id INTEGER default NULL, -- Example Values: `2`, `1` | Value Statics: Total count 11740 - Distinct count 2 - Null count 0 movie_id INTEGER default NULL, -- foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), language_id INTEGER default NULL, -- ); CREATE TABLE movie_crew ( job TEXT default NULL, -- person_id INTEGER default NULL, -- department_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 12 - Null count 0 foreign key (person_id) references person(person_id), movie_id INTEGER default NULL, -- foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL, -- ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL, -- ); CREATE TABLE movie_keywords ( movie_id INTEGER default NULL references movie, -- keyword_id INTEGER default NULL references keyword, -- ); CREATE TABLE language ( language_name TEXT default NULL, -- language_id INTEGER not null primary key, language_code TEXT default NULL, -- ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL, -- ); CREATE TABLE department ( department_name TEXT default NULL, -- Example Values: `Camera`, `Directing`, `Production`, `Writing`, `Editing` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 department_id INTEGER not null primary key, ); CREATE TABLE movie_cast ( foreign key (gender_id) references gender(gender_id), cast_order INTEGER default NULL, -- gender_id INTEGER default NULL, -- Example Values: `2`, `1`, `0` | Value Statics: Total count 59083 - Distinct count 3 - Null count 0 movie_id INTEGER default NULL, -- character_name TEXT default NULL, -- foreign key (movie_id) references movie(movie_id), person_id INTEGER default NULL, -- foreign key (person_id) references person(person_id), ); CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, -- country_name TEXT default NULL, -- ); CREATE TABLE movie_company ( movie_id INTEGER default NULL references movie, -- company_id INTEGER default NULL references production_company, -- ); CREATE TABLE production_country ( movie_id INTEGER default NULL, -- country_id INTEGER default NULL, -- foreign key (movie_id) references movie(movie_id), foreign key (country_id) references country(country_id), ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL, -- Example Values: `Original`, `Spoken` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 );
address
What is the total number of households in Arecibo county?
"ARECIBO" is the county; total number of households refer to sum(households)
SELECT SUM(T1.households) FROM zip_data AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code WHERE T2.county = 'ARECIBO'
CREATE TABLE state ( name TEXT, -- abbreviation TEXT primary key, ); CREATE TABLE country ( zip_code INTEGER, -- foreign key (state) references state(abbreviation), county TEXT, -- primary key (zip_code, county), state TEXT, -- foreign key (zip_code) references zip_data(zip_code), ); CREATE TABLE area_code ( primary key (zip_code, area_code), zip_code INTEGER, -- area_code INTEGER, -- foreign key (zip_code) references zip_data(zip_code), ); CREATE TABLE congress ( House TEXT, -- Example Values: `House of Repsentatives`, `Senate` | Value Statics: Total count 540 - Distinct count 2 - Null count 0 District INTEGER, -- land_area REAL, -- party TEXT, -- Example Values: `Republican`, `Democrat`, `Independent` | Value Statics: Total count 540 - Distinct count 3 - Null count 0 abbreviation TEXT, -- state TEXT, -- cognress_rep_id TEXT primary key, CID TEXT, -- foreign key (abbreviation) references state(abbreviation), first_name TEXT, -- last_name TEXT, -- ); CREATE TABLE avoid ( primary key (zip_code, bad_alias), bad_alias TEXT, -- foreign key (zip_code) references zip_data(zip_code), zip_code INTEGER, -- ); CREATE TABLE zip_data ( population_2010 INTEGER, -- "1st_quarter_payroll" INTEGER, -- residential_mailboxes INTEGER, -- american_indian_population INTEGER, -- spouses INTEGER, -- over_65 INTEGER, -- employees INTEGER, -- white_population INTEGER, -- multi_county TEXT, -- Example Values: `No`, `Yes` | Value Statics: Total count 41563 - Distinct count 2 - Null count 0 businesses INTEGER, -- black_population INTEGER, -- avg_house_value INTEGER, -- children INTEGER, -- foreign key (state) references state(abbreviation), single_family_delivery_units INTEGER, -- time_zone TEXT, -- Example Values: `Eastern`, `Atlantic`, `Central`, `Mountain`, `Pacific` | Value Statics: Total count 40955 - Distinct count 12 - Null count 608 parents_and_widowed INTEGER, -- state_fips INTEGER, -- monthly_benefits_all INTEGER, -- male_population INTEGER, -- type TEXT, -- Example Values: `Unique Post Office`, `Post Office`, `P.O. Box Only`, `Branch`, `Non Postal Community Name` | Value Statics: Total count 41563 - Distinct count 9 - Null count 0 population_2020 INTEGER, -- other_population INTEGER, -- avg_income_per_household INTEGER, -- daylight_savings TEXT, -- Example Values: `Yes`, `No` | Value Statics: Total count 41563 - Distinct count 2 - Null count 0 female_median_age REAL, -- annual_payroll INTEGER, -- female_population INTEGER, -- persons_per_household REAL, -- division TEXT, -- Example Values: `Middle Atlantic`, `New England`, `South Atlantic`, `East South Central`, `East North Central` | Value Statics: Total count 40725 - Distinct count 9 - Null count 838 city TEXT, -- total_delivery_receptacles INTEGER, -- organization TEXT, -- state TEXT, -- monthly_benefits_retired_workers INTEGER, -- foreign key (CBSA) references CBSA(CBSA), asian_population INTEGER, -- hispanic_population INTEGER, -- male_median_age REAL, -- region TEXT, -- Example Values: `Northeast`, `South`, `Midwest`, `West` | Value Statics: Total count 40725 - Distinct count 4 - Null count 838 county_fips INTEGER, -- median_age REAL, -- retired_workers INTEGER, -- total_beneficiaries INTEGER, -- latitude REAL, -- households INTEGER, -- hawaiian_population INTEGER, -- monthly_benefits_widowed INTEGER, -- water_area REAL, -- business_mailboxes INTEGER, -- longitude REAL, -- multi_family_delivery_units INTEGER, -- CBSA INTEGER, -- zip_code INTEGER primary key, elevation INTEGER, -- land_area REAL, -- disabled_workers INTEGER, -- ); CREATE TABLE alias ( foreign key (zip_code) references zip_data(zip_code), alias TEXT, -- zip_code INTEGER primary key, ); CREATE TABLE zip_congress ( district TEXT, -- foreign key (district) references congress(cognress_rep_id), primary key (zip_code, district), foreign key (zip_code) references zip_data(zip_code), zip_code INTEGER, -- ); CREATE TABLE CBSA ( CBSA_type TEXT, -- Example Values: `Micro`, `Metro` | Value Statics: Total count 465 - Distinct count 2 - Null count 0 CBSA INTEGER primary key, CBSA_name TEXT, -- );