db_id
stringclasses
20 values
query
stringlengths
25
323
question
stringlengths
22
144
create_w_keys
stringclasses
20 values
create_wo_keys
stringclasses
20 values
difficulty
stringclasses
4 values
zero_shot_request
stringlengths
527
3.29k
concert_singer
SELECT count(*) FROM singer
How many singers do we have?
CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") );
CREATE TABLE stadium (Stadium_ID INT, Location TEXT, Name TEXT, Capacity INT, Highest INT, Lowest INT, Average INT); CREATE TABLE singer (Singer_ID INT, Name TEXT, Country TEXT, Song_Name TEXT, Song_release_year TEXT, Age INT, Is_male bool); CREATE TABLE concert (concert_ID INT, concert_Name TEXT, Theme TEXT, Stadium_ID TEXT, Year TEXT); CREATE TABLE singer_in_concert (concert_ID INT, Singer_ID TEXT);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") ); QUESTION: How many singers do we have?
concert_singer
SELECT name , country , age FROM singer ORDER BY age DESC
Show name, country, age for all singers ordered by age from the oldest to the youngest.
CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") );
CREATE TABLE stadium (Stadium_ID INT, Location TEXT, Name TEXT, Capacity INT, Highest INT, Lowest INT, Average INT); CREATE TABLE singer (Singer_ID INT, Name TEXT, Country TEXT, Song_Name TEXT, Song_release_year TEXT, Age INT, Is_male bool); CREATE TABLE concert (concert_ID INT, concert_Name TEXT, Theme TEXT, Stadium_ID TEXT, Year TEXT); CREATE TABLE singer_in_concert (concert_ID INT, Singer_ID TEXT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") ); QUESTION: Show name, country, age for all singers ordered by age from the oldest to the youngest.
concert_singer
SELECT avg(age) , min(age) , max(age) FROM singer WHERE country = 'France'
What is the average, minimum, and maximum age of all singers from France?
CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") );
CREATE TABLE stadium (Stadium_ID INT, Location TEXT, Name TEXT, Capacity INT, Highest INT, Lowest INT, Average INT); CREATE TABLE singer (Singer_ID INT, Name TEXT, Country TEXT, Song_Name TEXT, Song_release_year TEXT, Age INT, Is_male bool); CREATE TABLE concert (concert_ID INT, concert_Name TEXT, Theme TEXT, Stadium_ID TEXT, Year TEXT); CREATE TABLE singer_in_concert (concert_ID INT, Singer_ID TEXT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") ); QUESTION: What is the average, minimum, and maximum age of all singers from France?
concert_singer
SELECT song_name , song_release_year FROM singer ORDER BY age LIMIT 1
Show the name and the release year of the song by the youngest singer.
CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") );
CREATE TABLE stadium (Stadium_ID INT, Location TEXT, Name TEXT, Capacity INT, Highest INT, Lowest INT, Average INT); CREATE TABLE singer (Singer_ID INT, Name TEXT, Country TEXT, Song_Name TEXT, Song_release_year TEXT, Age INT, Is_male bool); CREATE TABLE concert (concert_ID INT, concert_Name TEXT, Theme TEXT, Stadium_ID TEXT, Year TEXT); CREATE TABLE singer_in_concert (concert_ID INT, Singer_ID TEXT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") ); QUESTION: Show the name and the release year of the song by the youngest singer.
concert_singer
SELECT DISTINCT country FROM singer WHERE age > 20
What are all distinct countries where singers above age 20 are from?
CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") );
CREATE TABLE stadium (Stadium_ID INT, Location TEXT, Name TEXT, Capacity INT, Highest INT, Lowest INT, Average INT); CREATE TABLE singer (Singer_ID INT, Name TEXT, Country TEXT, Song_Name TEXT, Song_release_year TEXT, Age INT, Is_male bool); CREATE TABLE concert (concert_ID INT, concert_Name TEXT, Theme TEXT, Stadium_ID TEXT, Year TEXT); CREATE TABLE singer_in_concert (concert_ID INT, Singer_ID TEXT);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") ); QUESTION: What are all distinct countries where singers above age 20 are from?
concert_singer
SELECT song_name FROM singer WHERE age > (SELECT avg(age) FROM singer)
List all song names by singers above the average age.
CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") );
CREATE TABLE stadium (Stadium_ID INT, Location TEXT, Name TEXT, Capacity INT, Highest INT, Lowest INT, Average INT); CREATE TABLE singer (Singer_ID INT, Name TEXT, Country TEXT, Song_Name TEXT, Song_release_year TEXT, Age INT, Is_male bool); CREATE TABLE concert (concert_ID INT, concert_Name TEXT, Theme TEXT, Stadium_ID TEXT, Year TEXT); CREATE TABLE singer_in_concert (concert_ID INT, Singer_ID TEXT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") ); QUESTION: List all song names by singers above the average age.
concert_singer
SELECT T2.name , T2.capacity FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.year >= 2014 GROUP BY T2.stadium_id ORDER BY count(*) DESC LIMIT 1
Show the stadium name and capacity with most number of concerts in year 2014 or after.
CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") );
CREATE TABLE stadium (Stadium_ID INT, Location TEXT, Name TEXT, Capacity INT, Highest INT, Lowest INT, Average INT); CREATE TABLE singer (Singer_ID INT, Name TEXT, Country TEXT, Song_Name TEXT, Song_release_year TEXT, Age INT, Is_male bool); CREATE TABLE concert (concert_ID INT, concert_Name TEXT, Theme TEXT, Stadium_ID TEXT, Year TEXT); CREATE TABLE singer_in_concert (concert_ID INT, Singer_ID TEXT);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") ); QUESTION: Show the stadium name and capacity with most number of concerts in year 2014 or after.
concert_singer
select t2.name , t2.capacity from concert as t1 join stadium as t2 on t1.stadium_id = t2.stadium_id where t1.year > 2013 group by t2.stadium_id order by count(*) desc limit 1
What is the name and capacity of the stadium with the most concerts after 2013 ?
CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") );
CREATE TABLE stadium (Stadium_ID INT, Location TEXT, Name TEXT, Capacity INT, Highest INT, Lowest INT, Average INT); CREATE TABLE singer (Singer_ID INT, Name TEXT, Country TEXT, Song_Name TEXT, Song_release_year TEXT, Age INT, Is_male bool); CREATE TABLE concert (concert_ID INT, concert_Name TEXT, Theme TEXT, Stadium_ID TEXT, Year TEXT); CREATE TABLE singer_in_concert (concert_ID INT, Singer_ID TEXT);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") ); QUESTION: What is the name and capacity of the stadium with the most concerts after 2013 ?
concert_singer
SELECT YEAR FROM concert GROUP BY YEAR ORDER BY count(*) DESC LIMIT 1
Which year has most number of concerts?
CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") );
CREATE TABLE stadium (Stadium_ID INT, Location TEXT, Name TEXT, Capacity INT, Highest INT, Lowest INT, Average INT); CREATE TABLE singer (Singer_ID INT, Name TEXT, Country TEXT, Song_Name TEXT, Song_release_year TEXT, Age INT, Is_male bool); CREATE TABLE concert (concert_ID INT, concert_Name TEXT, Theme TEXT, Stadium_ID TEXT, Year TEXT); CREATE TABLE singer_in_concert (concert_ID INT, Singer_ID TEXT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") ); QUESTION: Which year has most number of concerts?
concert_singer
SELECT name FROM stadium WHERE stadium_id NOT IN (SELECT stadium_id FROM concert)
Show the stadium names without any concert.
CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") );
CREATE TABLE stadium (Stadium_ID INT, Location TEXT, Name TEXT, Capacity INT, Highest INT, Lowest INT, Average INT); CREATE TABLE singer (Singer_ID INT, Name TEXT, Country TEXT, Song_Name TEXT, Song_release_year TEXT, Age INT, Is_male bool); CREATE TABLE concert (concert_ID INT, concert_Name TEXT, Theme TEXT, Stadium_ID TEXT, Year TEXT); CREATE TABLE singer_in_concert (concert_ID INT, Singer_ID TEXT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") ); QUESTION: Show the stadium names without any concert.
concert_singer
SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2014 INTERSECT SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2015
Find the name and location of the stadiums which some concerts happened in the years of both 2014 and 2015.
CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") );
CREATE TABLE stadium (Stadium_ID INT, Location TEXT, Name TEXT, Capacity INT, Highest INT, Lowest INT, Average INT); CREATE TABLE singer (Singer_ID INT, Name TEXT, Country TEXT, Song_Name TEXT, Song_release_year TEXT, Age INT, Is_male bool); CREATE TABLE concert (concert_ID INT, concert_Name TEXT, Theme TEXT, Stadium_ID TEXT, Year TEXT); CREATE TABLE singer_in_concert (concert_ID INT, Singer_ID TEXT);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "stadium" ( "Stadium_ID" int, "Location" text, "Name" text, "Capacity" int, "Highest" int, "Lowest" int, "Average" int, PRIMARY KEY ("Stadium_ID") ); CREATE TABLE "singer" ( "Singer_ID" int, "Name" text, "Country" text, "Song_Name" text, "Song_release_year" text, "Age" int, "Is_male" bool, PRIMARY KEY ("Singer_ID") ); CREATE TABLE "concert" ( "concert_ID" int, "concert_Name" text, "Theme" text, "Stadium_ID" text, "Year" text, PRIMARY KEY ("concert_ID"), FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID") ); CREATE TABLE "singer_in_concert" ( "concert_ID" int, "Singer_ID" text, PRIMARY KEY ("concert_ID","Singer_ID"), FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"), FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID") ); QUESTION: Find the name and location of the stadiums which some concerts happened in the years of both 2014 and 2015.
pets_1
SELECT count(*) FROM pets WHERE weight > 10
Find the number of pets whose weight is heavier than 10.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL );
CREATE TABLE Student (StuID INTEGER, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3)); CREATE TABLE Has_Pet (StuID INTEGER, PetID INTEGER); CREATE TABLE Pets (PetID INTEGER, PetType VARCHAR(20), pet_age INTEGER, weight REAL);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL ); QUESTION: Find the number of pets whose weight is heavier than 10.
pets_1
SELECT weight FROM pets ORDER BY pet_age LIMIT 1
Find the weight of the youngest dog.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL );
CREATE TABLE Student (StuID INTEGER, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3)); CREATE TABLE Has_Pet (StuID INTEGER, PetID INTEGER); CREATE TABLE Pets (PetID INTEGER, PetType VARCHAR(20), pet_age INTEGER, weight REAL);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL ); QUESTION: Find the weight of the youngest dog.
pets_1
SELECT max(weight) , petType FROM pets GROUP BY petType
Find the maximum weight for each type of pet. List the maximum weight and pet type.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL );
CREATE TABLE Student (StuID INTEGER, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3)); CREATE TABLE Has_Pet (StuID INTEGER, PetID INTEGER); CREATE TABLE Pets (PetID INTEGER, PetType VARCHAR(20), pet_age INTEGER, weight REAL);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL ); QUESTION: Find the maximum weight for each type of pet. List the maximum weight and pet type.
pets_1
SELECT count(*) FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid WHERE T1.age > 20
Find number of pets owned by students who are older than 20.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL );
CREATE TABLE Student (StuID INTEGER, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3)); CREATE TABLE Has_Pet (StuID INTEGER, PetID INTEGER); CREATE TABLE Pets (PetID INTEGER, PetType VARCHAR(20), pet_age INTEGER, weight REAL);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL ); QUESTION: Find number of pets owned by students who are older than 20.
pets_1
SELECT count(*) FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T2.petid = T3.petid WHERE T1.sex = 'F' AND T3.pettype = 'dog'
Find the number of dog pets that are raised by female students (with sex F).
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL );
CREATE TABLE Student (StuID INTEGER, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3)); CREATE TABLE Has_Pet (StuID INTEGER, PetID INTEGER); CREATE TABLE Pets (PetID INTEGER, PetType VARCHAR(20), pet_age INTEGER, weight REAL);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL ); QUESTION: Find the number of dog pets that are raised by female students (with sex F).
pets_1
SELECT count(DISTINCT pettype) FROM pets
Find the number of distinct type of pets.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL );
CREATE TABLE Student (StuID INTEGER, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3)); CREATE TABLE Has_Pet (StuID INTEGER, PetID INTEGER); CREATE TABLE Pets (PetID INTEGER, PetType VARCHAR(20), pet_age INTEGER, weight REAL);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL ); QUESTION: Find the number of distinct type of pets.
pets_1
SELECT DISTINCT T1.Fname FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat' OR T3.pettype = 'dog'
Find the first name of students who have cat or dog pet.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL );
CREATE TABLE Student (StuID INTEGER, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3)); CREATE TABLE Has_Pet (StuID INTEGER, PetID INTEGER); CREATE TABLE Pets (PetID INTEGER, PetType VARCHAR(20), pet_age INTEGER, weight REAL);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL ); QUESTION: Find the first name of students who have cat or dog pet.
pets_1
select t1.fname from student as t1 join has_pet as t2 on t1.stuid = t2.stuid join pets as t3 on t3.petid = t2.petid where t3.pettype = 'cat' intersect select t1.fname from student as t1 join has_pet as t2 on t1.stuid = t2.stuid join pets as t3 on t3.petid = t2.petid where t3.pettype = 'dog'
Find the first name of students who have both cat and dog pets .
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL );
CREATE TABLE Student (StuID INTEGER, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3)); CREATE TABLE Has_Pet (StuID INTEGER, PetID INTEGER); CREATE TABLE Pets (PetID INTEGER, PetType VARCHAR(20), pet_age INTEGER, weight REAL);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL ); QUESTION: Find the first name of students who have both cat and dog pets .
pets_1
SELECT T1.Fname FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat' INTERSECT SELECT T1.Fname FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'dog'
What are the students' first names who have both cats and dogs as pets?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL );
CREATE TABLE Student (StuID INTEGER, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3)); CREATE TABLE Has_Pet (StuID INTEGER, PetID INTEGER); CREATE TABLE Pets (PetID INTEGER, PetType VARCHAR(20), pet_age INTEGER, weight REAL);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL ); QUESTION: What are the students' first names who have both cats and dogs as pets?
pets_1
SELECT stuid FROM student EXCEPT SELECT T1.stuid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat'
Find the id of students who do not have a cat pet.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL );
CREATE TABLE Student (StuID INTEGER, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3)); CREATE TABLE Has_Pet (StuID INTEGER, PetID INTEGER); CREATE TABLE Pets (PetID INTEGER, PetType VARCHAR(20), pet_age INTEGER, weight REAL);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL ); QUESTION: Find the id of students who do not have a cat pet.
pets_1
SELECT T1.lname FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pet_age = 3 AND T3.pettype = 'cat'
Find the last name of the student who has a cat that is age 3.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL );
CREATE TABLE Student (StuID INTEGER, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3)); CREATE TABLE Has_Pet (StuID INTEGER, PetID INTEGER); CREATE TABLE Pets (PetID INTEGER, PetType VARCHAR(20), pet_age INTEGER, weight REAL);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Has_Pet ( StuID INTEGER, PetID INTEGER, FOREIGN KEY(PetID) REFERENCES Pets(PetID), FOREIGN KEY(StuID) REFERENCES Student(StuID) ); create table Pets ( PetID INTEGER PRIMARY KEY, PetType VARCHAR(20), pet_age INTEGER, weight REAL ); QUESTION: Find the last name of the student who has a cat that is age 3.
car_1
SELECT count(*) FROM CONTINENTS;
How many continents are there?
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: How many continents are there?
car_1
SELECT T1.ContId , T1.Continent , count(*) FROM CONTINENTS AS T1 JOIN COUNTRIES AS T2 ON T1.ContId = T2.Continent GROUP BY T1.ContId;
How many countries does each continent have? List the continent id, continent name and the number of countries.
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: How many countries does each continent have? List the continent id, continent name and the number of countries.
car_1
SELECT count(*) FROM COUNTRIES;
How many countries are listed?
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: How many countries are listed?
car_1
SELECT T1.FullName , T1.Id , count(*) FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker GROUP BY T1.Id;
How many models does each car maker produce? List maker full name, id and the number.
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: How many models does each car maker produce? List maker full name, id and the number.
car_1
SELECT T1.Model FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id ORDER BY T2.horsepower ASC LIMIT 1;
Which model of the car has the minimum horsepower?
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: Which model of the car has the minimum horsepower?
car_1
SELECT T1.model FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id WHERE T2.Weight < (SELECT avg(Weight) FROM CARS_DATA)
Find the model of the car whose weight is below the average weight.
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: Find the model of the car whose weight is below the average weight.
car_1
SELECT DISTINCT T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker JOIN CAR_NAMES AS T3 ON T2.model = T3.model JOIN CARS_DATA AS T4 ON T3.MakeId = T4.id WHERE T4.year = '1970';
Find the name of the makers that produced some cars in the year of 1970?
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: Find the name of the makers that produced some cars in the year of 1970?
car_1
SELECT T2.Make , T1.Year FROM CARS_DATA AS T1 JOIN CAR_NAMES AS T2 ON T1.Id = T2.MakeId WHERE T1.Year = (SELECT min(YEAR) FROM CARS_DATA);
Find the make and production time of the cars that were produced in the earliest year?
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: Find the make and production time of the cars that were produced in the earliest year?
car_1
SELECT DISTINCT T1.model FROM MODEL_LIST AS T1 JOIN CAR_NAMES AS T2 ON T1.model = T2.model JOIN CARS_DATA AS T3 ON T2.MakeId = T3.id WHERE T3.year > 1980;
Which distinct car models are the produced after 1980?
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: Which distinct car models are the produced after 1980?
car_1
SELECT T1.Continent , count(*) FROM CONTINENTS AS T1 JOIN COUNTRIES AS T2 ON T1.ContId = T2.continent JOIN car_makers AS T3 ON T2.CountryId = T3.Country GROUP BY T1.Continent;
How many car makers are there in each continents? List the continent name and the count.
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: How many car makers are there in each continents? List the continent name and the count.
car_1
select count(*) , t2.fullname from model_list as t1 join car_makers as t2 on t1.maker = t2.id group by t2.id;
How many car models are produced by each maker ? Only list the count and the maker full name .
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: How many car models are produced by each maker ? Only list the count and the maker full name .
car_1
SELECT avg(mpg) FROM CARS_DATA WHERE Cylinders = 4;
What is the average miles per gallon(mpg) of the cars with 4 cylinders?
CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) );
CREATE TABLE continents (ContId INTEGER, Continent TEXT); CREATE TABLE countries (CountryId INTEGER, CountryName TEXT, Continent INTEGER); CREATE TABLE car_makers (Id INTEGER, Maker TEXT, FullName TEXT, Country TEXT); CREATE TABLE model_list (ModelId INTEGER, Maker INTEGER, Model TEXT); CREATE TABLE car_names (MakeId INTEGER, Model TEXT, Make TEXT); CREATE TABLE cars_data (Id INTEGER, MPG TEXT, Cylinders INTEGER, Edispl REAL, Horsepower TEXT, Weight INTEGER, Accelerate REAL, Year INTEGER);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "continents" ( "ContId" INTEGER PRIMARY KEY, "Continent" TEXT ); CREATE TABLE "countries" ( "CountryId" INTEGER PRIMARY KEY, "CountryName" TEXT, "Continent" INTEGER, FOREIGN KEY (Continent) REFERENCES continents(ContId) ); CREATE TABLE "car_makers" ( "Id" INTEGER PRIMARY KEY, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, FOREIGN KEY (Country) REFERENCES countries(CountryId) ); CREATE TABLE "model_list" ( "ModelId" INTEGER PRIMARY KEY, "Maker" INTEGER, "Model" TEXT UNIQUE, FOREIGN KEY (Maker) REFERENCES car_makers (Id) ); CREATE TABLE "car_names" ( "MakeId" INTEGER PRIMARY KEY, "Model" TEXT, "Make" TEXT, FOREIGN KEY (Model) REFERENCES model_list (Model) ); CREATE TABLE "cars_data" ( "Id" INTEGER PRIMARY KEY, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, FOREIGN KEY (Id) REFERENCES car_names (MakeId) ); QUESTION: What is the average miles per gallon(mpg) of the cars with 4 cylinders?
flight_2
SELECT Country FROM AIRLINES WHERE Airline = "JetBlue Airways"
Which country does Airline "JetBlue Airways" belong to?
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: Which country does Airline "JetBlue Airways" belong to?
flight_2
SELECT Abbreviation FROM AIRLINES WHERE Airline = "JetBlue Airways"
What is the abbreviation of Airline "JetBlue Airways"?
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: What is the abbreviation of Airline "JetBlue Airways"?
flight_2
SELECT Airline , Abbreviation FROM AIRLINES WHERE Country = "USA"
List all airline names and their abbreviations in "USA".
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: List all airline names and their abbreviations in "USA".
flight_2
SELECT AirportCode , AirportName FROM AIRPORTS WHERE city = "Anthony"
List the airport code and name in the city of Anthony.
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: List the airport code and name in the city of Anthony.
flight_2
SELECT count(*) FROM AIRLINES
How many airlines do we have?
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: How many airlines do we have?
flight_2
SELECT City , Country FROM AIRPORTS WHERE AirportName = "Alton"
Which city and country is the Alton airport at?
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: Which city and country is the Alton airport at?
flight_2
SELECT count(*) FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport = T2.AirportCode JOIN AIRPORTS AS T3 ON T1.SourceAirport = T3.AirportCode WHERE T2.City = "Ashley" AND T3.City = "Aberdeen"
How many flights depart from City 'Aberdeen' and have destination City 'Ashley'?
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: How many flights depart from City 'Aberdeen' and have destination City 'Ashley'?
flight_2
SELECT count(*) FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport = T2.AirportCode JOIN AIRLINES AS T3 ON T3.uid = T1.Airline WHERE T2.City = "Aberdeen" AND T3.Airline = "United Airlines"
How many United Airlines flights go to City 'Aberdeen'?
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: How many United Airlines flights go to City 'Aberdeen'?
flight_2
SELECT T1.City FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode = T2.DestAirport GROUP BY T1.City ORDER BY count(*) DESC LIMIT 1
Which city has most number of arriving flights?
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: Which city has most number of arriving flights?
flight_2
SELECT T1.City FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode = T2.SourceAirport GROUP BY T1.City ORDER BY count(*) DESC LIMIT 1
Which city has most number of departing flights?
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: Which city has most number of departing flights?
flight_2
SELECT T1.AirportCode FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode = T2.DestAirport OR T1.AirportCode = T2.SourceAirport GROUP BY T1.AirportCode ORDER BY count(*) DESC LIMIT 1
What is the code of airport that has the highest number of flights?
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: What is the code of airport that has the highest number of flights?
flight_2
SELECT count(*) FROM Flights AS T1 JOIN Airports AS T2 ON T1.DestAirport = T2.AirportCode WHERE T2.city = "Aberdeen" OR T2.city = "Abilene"
Find the number of flights landing in the city of Aberdeen or Abilene.
CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) );
CREATE TABLE airlines (uid INTEGER, Airline TEXT, Abbreviation TEXT, Country TEXT); CREATE TABLE airports (City TEXT, AirportCode TEXT, AirportName TEXT, Country TEXT, CountryAbbrev TEXT); CREATE TABLE flights (Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE 'airlines' ( uid INTEGER PRIMARY KEY, Airline TEXT, Abbreviation TEXT, Country TEXT ); CREATE TABLE 'airports' ( City TEXT, AirportCode TEXT PRIMARY KEY, AirportName TEXT, Country TEXT, CountryAbbrev TEXT ); CREATE TABLE 'flights' ( Airline INTEGER, FlightNo INTEGER, SourceAirport TEXT, DestAirport TEXT, PRIMARY KEY(Airline, FlightNo), FOREIGN KEY (SourceAirport) REFERENCES airports(AirportCode), FOREIGN KEY (DestAirport) REFERENCES airports(AirportCode) ); QUESTION: Find the number of flights landing in the city of Aberdeen or Abilene.
employee_hire_evaluation
SELECT count(*) FROM employee
How many employees are there?
CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) );
CREATE TABLE employee (Employee_ID INT, Name TEXT, Age INT, City TEXT); CREATE TABLE shop (Shop_ID INT, Name TEXT, Location TEXT, District TEXT, Number_products INT, Manager_name TEXT); CREATE TABLE hiring (Shop_ID INT, Employee_ID INT, Start_from TEXT, Is_full_time bool); CREATE TABLE evaluation (Employee_ID TEXT, Year_awarded TEXT, Bonus REAL);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); QUESTION: How many employees are there?
employee_hire_evaluation
SELECT name FROM employee ORDER BY age
Sort employee names by their age in ascending order.
CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) );
CREATE TABLE employee (Employee_ID INT, Name TEXT, Age INT, City TEXT); CREATE TABLE shop (Shop_ID INT, Name TEXT, Location TEXT, District TEXT, Number_products INT, Manager_name TEXT); CREATE TABLE hiring (Shop_ID INT, Employee_ID INT, Start_from TEXT, Is_full_time bool); CREATE TABLE evaluation (Employee_ID TEXT, Year_awarded TEXT, Bonus REAL);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); QUESTION: Sort employee names by their age in ascending order.
employee_hire_evaluation
SELECT count(*) , city FROM employee GROUP BY city
What is the number of employees from each city?
CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) );
CREATE TABLE employee (Employee_ID INT, Name TEXT, Age INT, City TEXT); CREATE TABLE shop (Shop_ID INT, Name TEXT, Location TEXT, District TEXT, Number_products INT, Manager_name TEXT); CREATE TABLE hiring (Shop_ID INT, Employee_ID INT, Start_from TEXT, Is_full_time bool); CREATE TABLE evaluation (Employee_ID TEXT, Year_awarded TEXT, Bonus REAL);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); QUESTION: What is the number of employees from each city?
employee_hire_evaluation
SELECT city FROM employee WHERE age < 30 GROUP BY city HAVING count(*) > 1
Which cities do more than one employee under age 30 come from?
CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) );
CREATE TABLE employee (Employee_ID INT, Name TEXT, Age INT, City TEXT); CREATE TABLE shop (Shop_ID INT, Name TEXT, Location TEXT, District TEXT, Number_products INT, Manager_name TEXT); CREATE TABLE hiring (Shop_ID INT, Employee_ID INT, Start_from TEXT, Is_full_time bool); CREATE TABLE evaluation (Employee_ID TEXT, Year_awarded TEXT, Bonus REAL);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); QUESTION: Which cities do more than one employee under age 30 come from?
employee_hire_evaluation
SELECT count(*) , LOCATION FROM shop GROUP BY LOCATION
Find the number of shops in each location.
CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) );
CREATE TABLE employee (Employee_ID INT, Name TEXT, Age INT, City TEXT); CREATE TABLE shop (Shop_ID INT, Name TEXT, Location TEXT, District TEXT, Number_products INT, Manager_name TEXT); CREATE TABLE hiring (Shop_ID INT, Employee_ID INT, Start_from TEXT, Is_full_time bool); CREATE TABLE evaluation (Employee_ID TEXT, Year_awarded TEXT, Bonus REAL);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); QUESTION: Find the number of shops in each location.
employee_hire_evaluation
SELECT name FROM shop WHERE number_products > (SELECT avg(number_products) FROM shop)
Find the names of stores whose number products is more than the average number of products.
CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) );
CREATE TABLE employee (Employee_ID INT, Name TEXT, Age INT, City TEXT); CREATE TABLE shop (Shop_ID INT, Name TEXT, Location TEXT, District TEXT, Number_products INT, Manager_name TEXT); CREATE TABLE hiring (Shop_ID INT, Employee_ID INT, Start_from TEXT, Is_full_time bool); CREATE TABLE evaluation (Employee_ID TEXT, Year_awarded TEXT, Bonus REAL);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); QUESTION: Find the names of stores whose number products is more than the average number of products.
employee_hire_evaluation
SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID = t2.Employee_ID GROUP BY t2.Employee_ID ORDER BY count(*) DESC LIMIT 1
find the name of employee who was awarded the most times in the evaluation.
CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) );
CREATE TABLE employee (Employee_ID INT, Name TEXT, Age INT, City TEXT); CREATE TABLE shop (Shop_ID INT, Name TEXT, Location TEXT, District TEXT, Number_products INT, Manager_name TEXT); CREATE TABLE hiring (Shop_ID INT, Employee_ID INT, Start_from TEXT, Is_full_time bool); CREATE TABLE evaluation (Employee_ID TEXT, Year_awarded TEXT, Bonus REAL);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); QUESTION: find the name of employee who was awarded the most times in the evaluation.
employee_hire_evaluation
SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID = t2.Employee_ID ORDER BY t2.bonus DESC LIMIT 1
Find the name of the employee who got the highest one time bonus.
CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) );
CREATE TABLE employee (Employee_ID INT, Name TEXT, Age INT, City TEXT); CREATE TABLE shop (Shop_ID INT, Name TEXT, Location TEXT, District TEXT, Number_products INT, Manager_name TEXT); CREATE TABLE hiring (Shop_ID INT, Employee_ID INT, Start_from TEXT, Is_full_time bool); CREATE TABLE evaluation (Employee_ID TEXT, Year_awarded TEXT, Bonus REAL);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); QUESTION: Find the name of the employee who got the highest one time bonus.
employee_hire_evaluation
SELECT name FROM employee WHERE Employee_ID NOT IN (SELECT Employee_ID FROM evaluation)
Find the names of employees who never won any award in the evaluation.
CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) );
CREATE TABLE employee (Employee_ID INT, Name TEXT, Age INT, City TEXT); CREATE TABLE shop (Shop_ID INT, Name TEXT, Location TEXT, District TEXT, Number_products INT, Manager_name TEXT); CREATE TABLE hiring (Shop_ID INT, Employee_ID INT, Start_from TEXT, Is_full_time bool); CREATE TABLE evaluation (Employee_ID TEXT, Year_awarded TEXT, Bonus REAL);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); QUESTION: Find the names of employees who never won any award in the evaluation.
employee_hire_evaluation
SELECT t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id = t2.shop_id GROUP BY t1.shop_id ORDER BY count(*) DESC LIMIT 1
What is the name of the shop that is hiring the largest number of employees?
CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) );
CREATE TABLE employee (Employee_ID INT, Name TEXT, Age INT, City TEXT); CREATE TABLE shop (Shop_ID INT, Name TEXT, Location TEXT, District TEXT, Number_products INT, Manager_name TEXT); CREATE TABLE hiring (Shop_ID INT, Employee_ID INT, Start_from TEXT, Is_full_time bool); CREATE TABLE evaluation (Employee_ID TEXT, Year_awarded TEXT, Bonus REAL);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); QUESTION: What is the name of the shop that is hiring the largest number of employees?
employee_hire_evaluation
SELECT sum(bonus) FROM evaluation
What is total bonus given in all evaluations?
CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) );
CREATE TABLE employee (Employee_ID INT, Name TEXT, Age INT, City TEXT); CREATE TABLE shop (Shop_ID INT, Name TEXT, Location TEXT, District TEXT, Number_products INT, Manager_name TEXT); CREATE TABLE hiring (Shop_ID INT, Employee_ID INT, Start_from TEXT, Is_full_time bool); CREATE TABLE evaluation (Employee_ID TEXT, Year_awarded TEXT, Bonus REAL);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "employee" ( "Employee_ID" int, "Name" text, "Age" int, "City" text, PRIMARY KEY ("Employee_ID") ); CREATE TABLE "shop" ( "Shop_ID" int, "Name" text, "Location" text, "District" text, "Number_products" int, "Manager_name" text, PRIMARY KEY ("Shop_ID") ); CREATE TABLE "hiring" ( "Shop_ID" int, "Employee_ID" int, "Start_from" text, "Is_full_time" bool, PRIMARY KEY ("Employee_ID"), FOREIGN KEY (`Shop_ID`) REFERENCES `shop`(`Shop_ID`), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); CREATE TABLE "evaluation" ( "Employee_ID" text, "Year_awarded" text, "Bonus" real, PRIMARY KEY ("Employee_ID","Year_awarded"), FOREIGN KEY (`Employee_ID`) REFERENCES `employee`(`Employee_ID`) ); QUESTION: What is total bonus given in all evaluations?
cre_Doc_Template_Mgt
SELECT count(*) FROM Documents
How many documents do we have?
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: How many documents do we have?
cre_Doc_Template_Mgt
SELECT document_id , document_name , document_description FROM Documents
List document IDs, document names, and document descriptions for all documents.
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: List document IDs, document names, and document descriptions for all documents.
cre_Doc_Template_Mgt
SELECT document_name , template_id FROM Documents WHERE Document_Description LIKE "%w%"
What is the document name and template id for document with description with the letter 'w' in it?
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: What is the document name and template id for document with description with the letter 'w' in it?
cre_Doc_Template_Mgt
SELECT document_id , template_id , Document_Description FROM Documents WHERE document_name = "Robbin CV"
What is the document id, template id and description for document named "Robbin CV"?
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: What is the document id, template id and description for document named "Robbin CV"?
cre_Doc_Template_Mgt
SELECT count(DISTINCT template_id) FROM Documents
How many different templates do all document use?
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: How many different templates do all document use?
cre_Doc_Template_Mgt
SELECT T1.template_id , T2.Template_Type_Code FROM Documents AS T1 JOIN Templates AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_id ORDER BY count(*) DESC LIMIT 1
What is the id and type code for the template used by the most documents?
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: What is the id and type code for the template used by the most documents?
cre_Doc_Template_Mgt
SELECT template_id FROM Documents GROUP BY template_id HAVING count(*) > 1
Show ids for all templates that are used by more than one document.
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: Show ids for all templates that are used by more than one document.
cre_Doc_Template_Mgt
SELECT template_id FROM Templates EXCEPT SELECT template_id FROM Documents
Show ids for all templates not used by any document.
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: Show ids for all templates not used by any document.
cre_Doc_Template_Mgt
SELECT template_type_code FROM Templates GROUP BY template_type_code ORDER BY count(*) DESC LIMIT 1
Which template type code has most number of templates?
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: Which template type code has most number of templates?
cre_Doc_Template_Mgt
SELECT T1.template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code ORDER BY count(*) DESC LIMIT 1
Which template type code is used by most number of documents?
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: Which template type code is used by most number of documents?
cre_Doc_Template_Mgt
SELECT template_type_code FROM Templates EXCEPT SELECT template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id
Show all template type codes that are not used by any document.
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: Show all template type codes that are not used by any document.
cre_Doc_Template_Mgt
SELECT T1.document_id , T2.document_name FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id GROUP BY T1.document_id ORDER BY count(*) DESC LIMIT 1
What is the document id and name with greatest number of paragraphs?
CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) );
CREATE TABLE Ref_Template_Types (Template_Type_Code CHAR(15), Template_Type_Description VARCHAR(255)); CREATE TABLE Templates (Template_ID INTEGER, Version_Number INTEGER, Template_Type_Code CHAR(15), Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255)); CREATE TABLE Documents (Document_ID INTEGER, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255)); CREATE TABLE Paragraphs (Paragraph_ID INTEGER, Document_ID INTEGER, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255));
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE Ref_Template_Types ( Template_Type_Code CHAR(15) NOT NULL, Template_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Template_Type_Code) ); CREATE TABLE Templates ( Template_ID INTEGER NOT NULL, Version_Number INTEGER NOT NULL, Template_Type_Code CHAR(15) NOT NULL, Date_Effective_From DATETIME, Date_Effective_To DATETIME, Template_Details VARCHAR(255) NOT NULL, PRIMARY KEY (Template_ID), FOREIGN KEY (Template_Type_Code) REFERENCES Ref_Template_Types (Template_Type_Code) ); CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Template_ID INTEGER, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Template_ID) REFERENCES Templates (Template_ID) ); CREATE TABLE Paragraphs ( Paragraph_ID INTEGER NOT NULL, Document_ID INTEGER NOT NULL, Paragraph_Text VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Paragraph_ID), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ); QUESTION: What is the document id and name with greatest number of paragraphs?
course_teach
SELECT count(*) FROM teacher
How many teachers are there?
CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") );
CREATE TABLE course (Course_ID INT, Staring_Date TEXT, Course TEXT); CREATE TABLE teacher (Teacher_ID INT, Name TEXT, Age TEXT, Hometown TEXT); CREATE TABLE course_arrange (Course_ID INT, Teacher_ID INT, Grade INT);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") ); QUESTION: How many teachers are there?
course_teach
SELECT Name FROM teacher ORDER BY Age ASC
List the names of teachers in ascending order of age.
CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") );
CREATE TABLE course (Course_ID INT, Staring_Date TEXT, Course TEXT); CREATE TABLE teacher (Teacher_ID INT, Name TEXT, Age TEXT, Hometown TEXT); CREATE TABLE course_arrange (Course_ID INT, Teacher_ID INT, Grade INT);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") ); QUESTION: List the names of teachers in ascending order of age.
course_teach
SELECT Age , Hometown FROM teacher
What are the age and hometown of teachers?
CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") );
CREATE TABLE course (Course_ID INT, Staring_Date TEXT, Course TEXT); CREATE TABLE teacher (Teacher_ID INT, Name TEXT, Age TEXT, Hometown TEXT); CREATE TABLE course_arrange (Course_ID INT, Teacher_ID INT, Grade INT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") ); QUESTION: What are the age and hometown of teachers?
course_teach
select name from teacher where hometown != "little lever urban district"
List the name of teachers whose hometown is not `` Little Lever Urban District '' .
CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") );
CREATE TABLE course (Course_ID INT, Staring_Date TEXT, Course TEXT); CREATE TABLE teacher (Teacher_ID INT, Name TEXT, Age TEXT, Hometown TEXT); CREATE TABLE course_arrange (Course_ID INT, Teacher_ID INT, Grade INT);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") ); QUESTION: List the name of teachers whose hometown is not `` Little Lever Urban District '' .
course_teach
SELECT Name FROM teacher WHERE Age = 32 OR Age = 33
Show the name of teachers aged either 32 or 33?
CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") );
CREATE TABLE course (Course_ID INT, Staring_Date TEXT, Course TEXT); CREATE TABLE teacher (Teacher_ID INT, Name TEXT, Age TEXT, Hometown TEXT); CREATE TABLE course_arrange (Course_ID INT, Teacher_ID INT, Grade INT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") ); QUESTION: Show the name of teachers aged either 32 or 33?
course_teach
SELECT Hometown FROM teacher ORDER BY Age ASC LIMIT 1
What is the hometown of the youngest teacher?
CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") );
CREATE TABLE course (Course_ID INT, Staring_Date TEXT, Course TEXT); CREATE TABLE teacher (Teacher_ID INT, Name TEXT, Age TEXT, Hometown TEXT); CREATE TABLE course_arrange (Course_ID INT, Teacher_ID INT, Grade INT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") ); QUESTION: What is the hometown of the youngest teacher?
course_teach
SELECT Hometown FROM teacher GROUP BY Hometown ORDER BY COUNT(*) DESC LIMIT 1
List the most common hometown of teachers.
CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") );
CREATE TABLE course (Course_ID INT, Staring_Date TEXT, Course TEXT); CREATE TABLE teacher (Teacher_ID INT, Name TEXT, Age TEXT, Hometown TEXT); CREATE TABLE course_arrange (Course_ID INT, Teacher_ID INT, Grade INT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") ); QUESTION: List the most common hometown of teachers.
course_teach
SELECT T3.Name , T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name
Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.
CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") );
CREATE TABLE course (Course_ID INT, Staring_Date TEXT, Course TEXT); CREATE TABLE teacher (Teacher_ID INT, Name TEXT, Age TEXT, Hometown TEXT); CREATE TABLE course_arrange (Course_ID INT, Teacher_ID INT, Grade INT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") ); QUESTION: Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.
course_teach
SELECT T3.Name FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID WHERE T2.Course = "Math"
Show the name of the teacher for the math course.
CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") );
CREATE TABLE course (Course_ID INT, Staring_Date TEXT, Course TEXT); CREATE TABLE teacher (Teacher_ID INT, Name TEXT, Age TEXT, Hometown TEXT); CREATE TABLE course_arrange (Course_ID INT, Teacher_ID INT, Grade INT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "course" ( "Course_ID" int, "Staring_Date" text, "Course" text, PRIMARY KEY ("Course_ID") ); CREATE TABLE "teacher" ( "Teacher_ID" int, "Name" text, "Age" text, "Hometown" text, PRIMARY KEY ("Teacher_ID") ); CREATE TABLE "course_arrange" ( "Course_ID" int, "Teacher_ID" int, "Grade" int, PRIMARY KEY ("Course_ID","Teacher_ID","Grade"), FOREIGN KEY ("Course_ID") REFERENCES `course`("Course_ID"), FOREIGN KEY ("Teacher_ID") REFERENCES `teacher`("Teacher_ID") ); QUESTION: Show the name of the teacher for the math course.
museum_visit
SELECT count(*) FROM visitor WHERE age < 30
How many visitors below age 30 are there?
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: How many visitors below age 30 are there?
museum_visit
SELECT name FROM visitor WHERE Level_of_membership > 4 ORDER BY Level_of_membership DESC
Find the names of the visitors whose membership level is higher than 4, and order the results by the level from high to low.
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: Find the names of the visitors whose membership level is higher than 4, and order the results by the level from high to low.
museum_visit
SELECT avg(age) FROM visitor WHERE Level_of_membership <= 4
What is the average age of the visitors whose membership level is not higher than 4?
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: What is the average age of the visitors whose membership level is not higher than 4?
museum_visit
SELECT name , Level_of_membership FROM visitor WHERE Level_of_membership > 4 ORDER BY age DESC
Find the name and membership level of the visitors whose membership level is higher than 4, and sort by their age from old to young.
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: Find the name and membership level of the visitors whose membership level is higher than 4, and sort by their age from old to young.
museum_visit
SELECT museum_id , name FROM museum ORDER BY num_of_staff DESC LIMIT 1
Find the id and name of the museum that has the most staff members?
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: Find the id and name of the museum that has the most staff members?
museum_visit
SELECT avg(num_of_staff) FROM museum WHERE open_year < 2009
Find the average number of staff working for the museums that were open before 2009.
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: Find the average number of staff working for the museums that were open before 2009.
museum_visit
SELECT name FROM museum WHERE num_of_staff > (SELECT min(num_of_staff) FROM museum WHERE open_year > 2010)
find the names of museums which have more staff than the minimum staff number of all museums opened after 2010.
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: find the names of museums which have more staff than the minimum staff number of all museums opened after 2010.
museum_visit
SELECT t2.visitor_id , t1.name , t1.Level_of_membership FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id GROUP BY t2.visitor_id ORDER BY sum(t2.Total_spent) DESC LIMIT 1
What are the id, name and membership level of visitors who have spent the largest amount of money in total in all museum tickets?
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: What are the id, name and membership level of visitors who have spent the largest amount of money in total in all museum tickets?
museum_visit
SELECT t2.Museum_ID , t1.name FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID = t2.Museum_ID GROUP BY t2.Museum_ID ORDER BY count(*) DESC LIMIT 1
What are the id and name of the museum visited most times?
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: What are the id and name of the museum visited most times?
museum_visit
SELECT name FROM museum WHERE Museum_ID NOT IN (SELECT museum_id FROM visit)
What is the name of the museum that had no visitor yet?
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: What is the name of the museum that had no visitor yet?
museum_visit
SELECT t1.name , t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id ORDER BY t2.num_of_ticket DESC LIMIT 1
Find the name and age of the visitor who bought the most tickets at once.
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: Find the name and age of the visitor who bought the most tickets at once.
museum_visit
SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year < 2009 INTERSECT SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year > 2011
What is the name of the visitor who visited both a museum opened before 2009 and a museum opened after 2011?
CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") );
CREATE TABLE museum (Museum_ID INT, Name TEXT, Num_of_Staff INT, Open_Year TEXT); CREATE TABLE visitor (ID INT, Name TEXT, Level_of_membership INT, Age INT); CREATE TABLE visit (Museum_ID INT, visitor_ID TEXT, Num_of_Ticket INT, Total_spent REAL);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE "museum" ( "Museum_ID" int, "Name" text, "Num_of_Staff" int, "Open_Year" text, PRIMARY KEY ("Museum_ID") ); CREATE TABLE "visitor" ( "ID" int, "Name" text, "Level_of_membership" int, "Age" int, PRIMARY KEY ("ID") ); CREATE TABLE "visit" ( "Museum_ID" int, "visitor_ID" text, "Num_of_Ticket" int, "Total_spent" real, PRIMARY KEY ("Museum_ID","visitor_ID"), FOREIGN KEY ("Museum_ID") REFERENCES `museum`("Museum_ID"), FOREIGN KEY ("visitor_ID") REFERENCES `visitor`("ID") ); QUESTION: What is the name of the visitor who visited both a museum opened before 2009 and a museum opened after 2011?
wta_1
SELECT count(*) FROM players
Find the total number of players.
CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) );
CREATE TABLE players (player_id INT, first_name TEXT, last_name TEXT, hand TEXT, birth_date DATE, country_code TEXT); CREATE TABLE matches (best_of INT, draw_size INT, loser_age FLOAT, loser_entry TEXT, loser_hand TEXT, loser_ht INT, loser_id INT, loser_ioc TEXT, loser_name TEXT, loser_rank INT, loser_rank_points INT, loser_seed INT, match_num INT, minutes INT, round TEXT, score TEXT, surface TEXT, tourney_date DATE, tourney_id TEXT, tourney_level TEXT, tourney_name TEXT, winner_age FLOAT, winner_entry TEXT, winner_hand TEXT, winner_ht INT, winner_id INT, winner_ioc TEXT, winner_name TEXT, winner_rank INT, winner_rank_points INT, winner_seed INT, year INT); CREATE TABLE rankings (ranking_date DATE, ranking INT, player_id INT, ranking_points INT, tours INT);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) ); QUESTION: Find the total number of players.
wta_1
SELECT count(*) FROM matches
Find the total number of matches.
CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) );
CREATE TABLE players (player_id INT, first_name TEXT, last_name TEXT, hand TEXT, birth_date DATE, country_code TEXT); CREATE TABLE matches (best_of INT, draw_size INT, loser_age FLOAT, loser_entry TEXT, loser_hand TEXT, loser_ht INT, loser_id INT, loser_ioc TEXT, loser_name TEXT, loser_rank INT, loser_rank_points INT, loser_seed INT, match_num INT, minutes INT, round TEXT, score TEXT, surface TEXT, tourney_date DATE, tourney_id TEXT, tourney_level TEXT, tourney_name TEXT, winner_age FLOAT, winner_entry TEXT, winner_hand TEXT, winner_ht INT, winner_id INT, winner_ioc TEXT, winner_name TEXT, winner_rank INT, winner_rank_points INT, winner_seed INT, year INT); CREATE TABLE rankings (ranking_date DATE, ranking INT, player_id INT, ranking_points INT, tours INT);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) ); QUESTION: Find the total number of matches.
wta_1
SELECT first_name , birth_date FROM players WHERE country_code = 'USA'
List the first name and birth date of all players from the country with code USA.
CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) );
CREATE TABLE players (player_id INT, first_name TEXT, last_name TEXT, hand TEXT, birth_date DATE, country_code TEXT); CREATE TABLE matches (best_of INT, draw_size INT, loser_age FLOAT, loser_entry TEXT, loser_hand TEXT, loser_ht INT, loser_id INT, loser_ioc TEXT, loser_name TEXT, loser_rank INT, loser_rank_points INT, loser_seed INT, match_num INT, minutes INT, round TEXT, score TEXT, surface TEXT, tourney_date DATE, tourney_id TEXT, tourney_level TEXT, tourney_name TEXT, winner_age FLOAT, winner_entry TEXT, winner_hand TEXT, winner_ht INT, winner_id INT, winner_ioc TEXT, winner_name TEXT, winner_rank INT, winner_rank_points INT, winner_seed INT, year INT); CREATE TABLE rankings (ranking_date DATE, ranking INT, player_id INT, ranking_points INT, tours INT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) ); QUESTION: List the first name and birth date of all players from the country with code USA.
wta_1
SELECT avg(loser_age) , avg(winner_age) FROM matches
Find the average age of losers and winners of all matches.
CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) );
CREATE TABLE players (player_id INT, first_name TEXT, last_name TEXT, hand TEXT, birth_date DATE, country_code TEXT); CREATE TABLE matches (best_of INT, draw_size INT, loser_age FLOAT, loser_entry TEXT, loser_hand TEXT, loser_ht INT, loser_id INT, loser_ioc TEXT, loser_name TEXT, loser_rank INT, loser_rank_points INT, loser_seed INT, match_num INT, minutes INT, round TEXT, score TEXT, surface TEXT, tourney_date DATE, tourney_id TEXT, tourney_level TEXT, tourney_name TEXT, winner_age FLOAT, winner_entry TEXT, winner_hand TEXT, winner_ht INT, winner_id INT, winner_ioc TEXT, winner_name TEXT, winner_rank INT, winner_rank_points INT, winner_seed INT, year INT); CREATE TABLE rankings (ranking_date DATE, ranking INT, player_id INT, ranking_points INT, tours INT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) ); QUESTION: Find the average age of losers and winners of all matches.
wta_1
SELECT avg(winner_rank) FROM matches
Find the average rank of winners in all matches.
CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) );
CREATE TABLE players (player_id INT, first_name TEXT, last_name TEXT, hand TEXT, birth_date DATE, country_code TEXT); CREATE TABLE matches (best_of INT, draw_size INT, loser_age FLOAT, loser_entry TEXT, loser_hand TEXT, loser_ht INT, loser_id INT, loser_ioc TEXT, loser_name TEXT, loser_rank INT, loser_rank_points INT, loser_seed INT, match_num INT, minutes INT, round TEXT, score TEXT, surface TEXT, tourney_date DATE, tourney_id TEXT, tourney_level TEXT, tourney_name TEXT, winner_age FLOAT, winner_entry TEXT, winner_hand TEXT, winner_ht INT, winner_id INT, winner_ioc TEXT, winner_name TEXT, winner_rank INT, winner_rank_points INT, winner_seed INT, year INT); CREATE TABLE rankings (ranking_date DATE, ranking INT, player_id INT, ranking_points INT, tours INT);
easy
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) ); QUESTION: Find the average rank of winners in all matches.
wta_1
SELECT winner_name FROM matches WHERE YEAR = 2013 INTERSECT SELECT winner_name FROM matches WHERE YEAR = 2016
List the names of all winners who played in both 2013 and 2016.
CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) );
CREATE TABLE players (player_id INT, first_name TEXT, last_name TEXT, hand TEXT, birth_date DATE, country_code TEXT); CREATE TABLE matches (best_of INT, draw_size INT, loser_age FLOAT, loser_entry TEXT, loser_hand TEXT, loser_ht INT, loser_id INT, loser_ioc TEXT, loser_name TEXT, loser_rank INT, loser_rank_points INT, loser_seed INT, match_num INT, minutes INT, round TEXT, score TEXT, surface TEXT, tourney_date DATE, tourney_id TEXT, tourney_level TEXT, tourney_name TEXT, winner_age FLOAT, winner_entry TEXT, winner_hand TEXT, winner_ht INT, winner_id INT, winner_ioc TEXT, winner_name TEXT, winner_rank INT, winner_rank_points INT, winner_seed INT, year INT); CREATE TABLE rankings (ranking_date DATE, ranking INT, player_id INT, ranking_points INT, tours INT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) ); QUESTION: List the names of all winners who played in both 2013 and 2016.
wta_1
SELECT count(*) FROM matches WHERE YEAR = 2013 OR YEAR = 2016
List the number of all matches who played in years of 2013 or 2016.
CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) );
CREATE TABLE players (player_id INT, first_name TEXT, last_name TEXT, hand TEXT, birth_date DATE, country_code TEXT); CREATE TABLE matches (best_of INT, draw_size INT, loser_age FLOAT, loser_entry TEXT, loser_hand TEXT, loser_ht INT, loser_id INT, loser_ioc TEXT, loser_name TEXT, loser_rank INT, loser_rank_points INT, loser_seed INT, match_num INT, minutes INT, round TEXT, score TEXT, surface TEXT, tourney_date DATE, tourney_id TEXT, tourney_level TEXT, tourney_name TEXT, winner_age FLOAT, winner_entry TEXT, winner_hand TEXT, winner_ht INT, winner_id INT, winner_ioc TEXT, winner_name TEXT, winner_rank INT, winner_rank_points INT, winner_seed INT, year INT); CREATE TABLE rankings (ranking_date DATE, ranking INT, player_id INT, ranking_points INT, tours INT);
medium
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) ); QUESTION: List the number of all matches who played in years of 2013 or 2016.
wta_1
SELECT T1.country_code , T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'WTA Championships' INTERSECT SELECT T1.country_code , T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'Australian Open'
What are the country code and first name of the players who won in both tourney WTA Championships and Australian Open?
CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) );
CREATE TABLE players (player_id INT, first_name TEXT, last_name TEXT, hand TEXT, birth_date DATE, country_code TEXT); CREATE TABLE matches (best_of INT, draw_size INT, loser_age FLOAT, loser_entry TEXT, loser_hand TEXT, loser_ht INT, loser_id INT, loser_ioc TEXT, loser_name TEXT, loser_rank INT, loser_rank_points INT, loser_seed INT, match_num INT, minutes INT, round TEXT, score TEXT, surface TEXT, tourney_date DATE, tourney_id TEXT, tourney_level TEXT, tourney_name TEXT, winner_age FLOAT, winner_entry TEXT, winner_hand TEXT, winner_ht INT, winner_id INT, winner_ioc TEXT, winner_name TEXT, winner_rank INT, winner_rank_points INT, winner_seed INT, year INT); CREATE TABLE rankings (ranking_date DATE, ranking INT, player_id INT, ranking_points INT, tours INT);
extra
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) ); QUESTION: What are the country code and first name of the players who won in both tourney WTA Championships and Australian Open?
wta_1
SELECT T1.country_code , T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id ORDER BY T2.tours DESC LIMIT 1
Find the first name and country code of the player who did the most number of tours.
CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) );
CREATE TABLE players (player_id INT, first_name TEXT, last_name TEXT, hand TEXT, birth_date DATE, country_code TEXT); CREATE TABLE matches (best_of INT, draw_size INT, loser_age FLOAT, loser_entry TEXT, loser_hand TEXT, loser_ht INT, loser_id INT, loser_ioc TEXT, loser_name TEXT, loser_rank INT, loser_rank_points INT, loser_seed INT, match_num INT, minutes INT, round TEXT, score TEXT, surface TEXT, tourney_date DATE, tourney_id TEXT, tourney_level TEXT, tourney_name TEXT, winner_age FLOAT, winner_entry TEXT, winner_hand TEXT, winner_ht INT, winner_id INT, winner_ioc TEXT, winner_name TEXT, winner_rank INT, winner_rank_points INT, winner_seed INT, year INT); CREATE TABLE rankings (ranking_date DATE, ranking INT, player_id INT, ranking_points INT, tours INT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) ); QUESTION: Find the first name and country code of the player who did the most number of tours.
wta_1
SELECT YEAR FROM matches GROUP BY YEAR ORDER BY count(*) DESC LIMIT 1
Find the year that has the most number of matches.
CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) );
CREATE TABLE players (player_id INT, first_name TEXT, last_name TEXT, hand TEXT, birth_date DATE, country_code TEXT); CREATE TABLE matches (best_of INT, draw_size INT, loser_age FLOAT, loser_entry TEXT, loser_hand TEXT, loser_ht INT, loser_id INT, loser_ioc TEXT, loser_name TEXT, loser_rank INT, loser_rank_points INT, loser_seed INT, match_num INT, minutes INT, round TEXT, score TEXT, surface TEXT, tourney_date DATE, tourney_id TEXT, tourney_level TEXT, tourney_name TEXT, winner_age FLOAT, winner_entry TEXT, winner_hand TEXT, winner_ht INT, winner_id INT, winner_ioc TEXT, winner_name TEXT, winner_rank INT, winner_rank_points INT, winner_seed INT, year INT); CREATE TABLE rankings (ranking_date DATE, ranking INT, player_id INT, ranking_points INT, tours INT);
hard
Provide the SQL query that answers the QUESTION, with no explanation or special characters. CONTEXT: Relevant SQL tables, with their properties: CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE qualifying_matches( "best_of" INT, "draw_size" INT, "l_1stIn" TEXT, "l_1stWon" TEXT, "l_2ndWon" TEXT, "l_SvGms" TEXT, "l_ace" TEXT, "l_bpFaced" TEXT, "l_bpSaved" TEXT, "l_df" TEXT, "l_svpt" TEXT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "w_1stIn" TEXT, "w_1stWon" TEXT, "w_2ndWon" TEXT, "w_SvGms" TEXT, "w_ace" TEXT, "w_bpFaced" TEXT, "w_bpSaved" TEXT, "w_df" TEXT, "w_svpt" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ); CREATE TABLE rankings( "ranking_date" DATE, "ranking" INT, "player_id" INT, "ranking_points" INT, "tours" INT, FOREIGN KEY(player_id) REFERENCES players(player_id) ); QUESTION: Find the year that has the most number of matches.