DDL_schema
stringlengths
263
8.16k
query
stringlengths
18
577
question
stringlengths
3
224
db_id
stringlengths
3
31
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title , T2.year FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID ORDER BY T1.stars DESC LIMIT 3
What are the names and years of the movies that has the top 3 highest rating star?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title , T2.year FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID ORDER BY T1.stars DESC LIMIT 3
What are the names and years released for the movies with the top 3 highest ratings?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title , T1.stars , T2.director , max(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE director != "null" GROUP BY director
For each director, return the director's name together with the title of the movie they directed that received the highest rating among all of their movies, and the value of that rating. Ignore movies whose director is NULL.
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title , T1.stars , T2.director , max(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE director != "null" GROUP BY director
For each director, what are the titles and ratings for all the movies they reviewed?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title , T1.rID , T1.stars , min(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.rID
Find the title and star rating of the movie that got the least rating star for each reviewer.
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title , T1.rID , T1.stars , min(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.rID
For each reviewer id, what is the title and rating for the movie with the smallest rating?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title , T1.stars , T2.director , min(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T2.director
Find the title and score of the movie with the lowest rating among all movies directed by each director.
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title , T1.stars , T2.director , min(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T2.director
For each director, what is the title and score of their most poorly rated movie?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title , T1.mID FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.mID ORDER BY count(*) DESC LIMIT 1
What is the name of the movie that is rated by most of times?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title , T1.mID FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.mID ORDER BY count(*) DESC LIMIT 1
What is the name of the movie that has been reviewed the most?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars BETWEEN 3 AND 5
What are the titles of all movies that have rating star is between 3 and 5?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars BETWEEN 3 AND 5
What are the titles of all movies that have between 3 and 5 stars?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars > 3
Find the names of reviewers who had given higher than 3 star ratings.
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars > 3
What are the names of the reviewers who have rated a movie more than 3 stars before?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT mID , avg(stars) FROM Rating WHERE mID NOT IN (SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T2.name = "Brittany Harris") GROUP BY mID
Find the average rating star for each movie that are not reviewed by Brittany Harris.
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT mID , avg(stars) FROM Rating WHERE mID NOT IN (SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T2.name = "Brittany Harris") GROUP BY mID
What is the average rating for each movie that has never been reviewed by Brittany Harris?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT mID FROM Rating EXCEPT SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T2.name = "Brittany Harris"
What are the ids of the movies that are not reviewed by Brittany Harris.
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT mID FROM Rating EXCEPT SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T2.name = "Brittany Harris"
What are the ids of all moviest hat have not been reviewed by Britanny Harris?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT mID , avg(stars) FROM Rating GROUP BY mID HAVING count(*) >= 2
Find the average rating star for each movie that received at least 2 ratings.
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT mID , avg(stars) FROM Rating GROUP BY mID HAVING count(*) >= 2
For each movie that received more than 3 reviews, what is the average rating?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT rID FROM Rating EXCEPT SELECT rID FROM Rating WHERE stars = 4
find the ids of reviewers who did not give 4 star.
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT rID FROM Rating EXCEPT SELECT rID FROM Rating WHERE stars = 4
What are the ids of all reviewers who did not give 4 stars?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT rID FROM Rating WHERE stars != 4
Find the ids of reviewers who didn't only give 4 star.
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT rID FROM Rating WHERE stars != 4
What are the ids of all reviewers who have not given 4 stars at least once?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT DISTINCT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T3.name = 'Brittany Harris' OR T2.year > 2000
What are names of the movies that are either made after 2000 or reviewed by Brittany Harris?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT DISTINCT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T3.name = 'Brittany Harris' OR T2.year > 2000
What are the names of all movies that were made after 2000 or reviewed by Brittany Harris?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT title FROM Movie WHERE director = "James Cameron" OR YEAR < 1980
What are names of the movies that are either made before 1980 or directed by James Cameron?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT title FROM Movie WHERE director = "James Cameron" OR YEAR < 1980
What are the names of all movies made before 1980 or had James Cameron as the director?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars = 3 INTERSECT SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars = 4
What are the names of reviewers who had rated 3 star and 4 star?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars = 3 INTERSECT SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars = 4
What are the names of all reviewers that have given 3 or 4 stars for reviews?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars = 3 INTERSECT SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars = 4
What are the names of movies that get 3 star and 4 star?
movie_1
CREATE TABLE Movie( mID int primary key, title text, year int, director text ) CREATE TABLE Reviewer( rID int primary key, name text) CREATE TABLE Rating( rID int, mID int, stars int, ratingDate date, FOREIGN KEY (mID) references Movie(mID), FOREIGN KEY (rID) references Reviewer(rID) )
SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars = 3 INTERSECT SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars = 4
What are the names of all movies that received 3 or 4 stars?
movie_1
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT count(*) FROM county_public_safety
How many counties are there?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT count(*) FROM county_public_safety
Count the number of countries.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Name FROM county_public_safety ORDER BY Population DESC
List the names of counties in descending order of population.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Name FROM county_public_safety ORDER BY Population DESC
What are the names of the counties of public safety, ordered by population descending?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT DISTINCT Police_force FROM county_public_safety WHERE LOCATION != "East"
List the distinct police forces of counties whose location is not on east side.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT DISTINCT Police_force FROM county_public_safety WHERE LOCATION != "East"
What are the different police forces of counties that are not located in the East?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT min(Crime_rate) , max(Crime_rate) FROM county_public_safety
What are the minimum and maximum crime rate of counties?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT min(Crime_rate) , max(Crime_rate) FROM county_public_safety
Return the minimum and maximum crime rates across all counties.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Crime_rate FROM county_public_safety ORDER BY Police_officers ASC
Show the crime rates of counties in ascending order of number of police officers.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Crime_rate FROM county_public_safety ORDER BY Police_officers ASC
What are the crime rates of counties sorted by number of offices ascending?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Name FROM city ORDER BY Name ASC
What are the names of cities in ascending alphabetical order?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Name FROM city ORDER BY Name ASC
Return the names of cities, ordered alphabetically.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Hispanic FROM city WHERE Black > 10
What are the percentage of hispanics in cities with the black percentage higher than 10?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Hispanic FROM city WHERE Black > 10
Return the hispanic percentage for cities in which the black percentage is greater than 10.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Name FROM county_public_safety ORDER BY Population DESC LIMIT 1
List the name of the county with the largest population.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Name FROM county_public_safety ORDER BY Population DESC LIMIT 1
What is the name of the county with the greatest population?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Name FROM city ORDER BY White DESC LIMIT 5
List the names of the city with the top 5 white percentages.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Name FROM city ORDER BY White DESC LIMIT 5
What are the names of the five cities with the greatest proportion of white people?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT T1.Name , T2.Name FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID
Show names of cities and names of counties they are in.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT T1.Name , T2.Name FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID
What are the names of cities, as well as the names of the counties they correspond to?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT T1.White , T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID
Show white percentages of cities and the crime rates of counties they are in.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT T1.White , T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID
What are the white percentages of cities, and the corresponding crime rates of the counties they correspond to?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT name FROM city WHERE county_ID = (SELECT county_ID FROM county_public_safety ORDER BY Police_officers DESC LIMIT 1)
Show the name of cities in the county that has the largest number of police officers.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT name FROM city WHERE county_ID = (SELECT county_ID FROM county_public_safety ORDER BY Police_officers DESC LIMIT 1)
What are the names of cities that are in the county with the most police officers?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT count(*) FROM city WHERE county_ID IN (SELECT county_ID FROM county_public_safety WHERE population > 20000)
Show the number of cities in counties that have a population more than 20000.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT count(*) FROM city WHERE county_ID IN (SELECT county_ID FROM county_public_safety WHERE population > 20000)
How many cities are in counties that have populations of over 20000?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID WHERE T1.White > 90
Show the crime rate of counties with a city having white percentage more than 90.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID WHERE T1.White > 90
What are the crime rates of counties that contain cities that have white percentages of over 90?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Police_force , COUNT(*) FROM county_public_safety GROUP BY Police_force
Please show the police forces and the number of counties with each police force.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Police_force , COUNT(*) FROM county_public_safety GROUP BY Police_force
How many counties correspond to each police force?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT LOCATION FROM county_public_safety GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1
What is the location shared by most counties?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT LOCATION FROM county_public_safety GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1
Which location has the most corresponding counties?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Name FROM county_public_safety WHERE County_ID NOT IN (SELECT County_ID FROM city)
List the names of counties that do not have any cities.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Name FROM county_public_safety WHERE County_ID NOT IN (SELECT County_ID FROM city)
What are the names of counties that do not contain any cities?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Police_force FROM county_public_safety WHERE LOCATION = "East" INTERSECT SELECT Police_force FROM county_public_safety WHERE LOCATION = "West"
Show the police force shared by counties with location on the east and west.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Police_force FROM county_public_safety WHERE LOCATION = "East" INTERSECT SELECT Police_force FROM county_public_safety WHERE LOCATION = "West"
Which police forces operate in both counties that are located in the East and in the West?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT name FROM city WHERE county_id IN (SELECT county_id FROM county_public_safety WHERE Crime_rate < 100)
Show the names of cities in counties that have a crime rate less than 100.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT name FROM city WHERE county_id IN (SELECT county_id FROM county_public_safety WHERE Crime_rate < 100)
What are the names of cities that are in counties that have a crime rate below 100?
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Case_burden FROM county_public_safety ORDER BY Population DESC
Show the case burden of counties in descending order of population.
county_public_safety
CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ) CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") )
SELECT Case_burden FROM county_public_safety ORDER BY Population DESC
What are the case burdens of counties, ordered descending by population?
county_public_safety
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT roomName FROM Rooms WHERE basePrice < 160 AND beds = 2 AND decor = 'modern';
Find the names of all modern rooms with a base price below $160 and two beds.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT roomName FROM Rooms WHERE basePrice < 160 AND beds = 2 AND decor = 'modern';
What are the names of modern rooms that have a base price lower than $160 and two beds.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT roomName , RoomId FROM Rooms WHERE basePrice > 160 AND maxOccupancy > 2;
Find all the rooms that have a price higher than 160 and can accommodate more than 2 people. Report room names and ids.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT roomName , RoomId FROM Rooms WHERE basePrice > 160 AND maxOccupancy > 2;
What are the room names and ids of all the rooms that cost more than 160 and can accommodate more than two people.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT T2.roomName FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room ORDER BY count(*) DESC LIMIT 1;
Find the most popular room in the hotel. The most popular room is the room that had seen the largest number of reservations.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT T2.roomName FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room ORDER BY count(*) DESC LIMIT 1;
Which room has the largest number of reservations?
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT kids FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY";
How many kids stay in the rooms reserved by ROY SWEAZY?
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT kids FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY";
Find the number of kids staying in the rooms reserved by a person called ROY SWEAZ.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT count(*) FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY";
How many times does ROY SWEAZY has reserved a room.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT count(*) FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY";
Find the number of times ROY SWEAZY has reserved a room.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT T2.roomName , T1.Rate , T1.CheckIn , T1.CheckOut FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room ORDER BY T1.Rate DESC LIMIT 1;
Which room has the highest rate? List the room's full name, rate, check in and check out date.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT T2.roomName , T1.Rate , T1.CheckIn , T1.CheckOut FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room ORDER BY T1.Rate DESC LIMIT 1;
Return the name, rate, check in and check out date for the room with the highest rate.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT Adults FROM Reservations WHERE CheckIn = "2010-10-23" AND FirstName = "CONRAD" AND LastName = "SELBIG";
How many adults stay in the room CONRAD SELBIG checked in on Oct 23, 2010?
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT Adults FROM Reservations WHERE CheckIn = "2010-10-23" AND FirstName = "CONRAD" AND LastName = "SELBIG";
Find the number of adults for the room reserved and checked in by CONRAD SELBIG on Oct 23, 2010.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT Kids FROM Reservations WHERE CheckIn = "2010-09-21" AND FirstName = "DAMIEN" AND LastName = "TRACHSEL";
How many kids stay in the room DAMIEN TRACHSEL checked in on Sep 21, 2010?
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT Kids FROM Reservations WHERE CheckIn = "2010-09-21" AND FirstName = "DAMIEN" AND LastName = "TRACHSEL";
Return the number of kids for the room reserved and checked in by DAMIEN TRACHSEL on Sep 21, 2010.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT sum(beds) FROM Rooms WHERE bedtype = 'King';
How many king beds are there?
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT sum(beds) FROM Rooms WHERE bedtype = 'King';
Find the total number of king beds available.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT roomName , decor FROM Rooms WHERE bedtype = 'King' ORDER BY basePrice;
List the names and decor of rooms that have a king bed. Sort the list by their price.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT roomName , decor FROM Rooms WHERE bedtype = 'King' ORDER BY basePrice;
What are the names and decor of rooms with a king bed? Sort them by their price
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT roomName , basePrice FROM Rooms ORDER BY basePrice ASC LIMIT 1;
Which room has cheapest base price? List the room's name and the base price.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT roomName , basePrice FROM Rooms ORDER BY basePrice ASC LIMIT 1;
What are the room name and base price of the room with the lowest base price?
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT decor FROM Rooms WHERE roomName = "Recluse and defiance";
What is the decor of room Recluse and defiance?
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT decor FROM Rooms WHERE roomName = "Recluse and defiance";
Return the decor of the room named "Recluse and defiance".
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT bedType , avg(basePrice) FROM Rooms GROUP BY bedType;
What is the average base price of different bed type? List bed type and average base price.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT bedType , avg(basePrice) FROM Rooms GROUP BY bedType;
For each bed type, find the average base price of different bed type.
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT sum(maxOccupancy) FROM Rooms WHERE decor = 'modern';
What is the total number of people who could stay in the modern rooms in this inn?
inn_1
CREATE TABLE "Rooms" ( "RoomId" TEXT PRIMARY KEY, "roomName" TEXT, "beds" INTEGER, "bedType" TEXT, "maxOccupancy" INTEGER, "basePrice" INTEGER, "decor" TEXT ) CREATE TABLE "Reservations" ( "Code" INTEGER PRIMARY KEY, "Room" TEXT, "CheckIn" TEXT, "CheckOut" TEXT, "Rate" REAL, "LastName" TEXT, "FirstName" TEXT, "Adults" INTEGER, "Kids" INTEGER, FOREIGN KEY (Room) REFERENCES Rooms(RoomId) )
SELECT sum(maxOccupancy) FROM Rooms WHERE decor = 'modern';
How many people in total can stay in the modern rooms of this inn?
inn_1