db_id stringclasses 146
values | question stringlengths 3 224 | sql stringlengths 18 577 | database_schema stringclasses 146
values |
|---|---|---|---|
movie_1 | What are the names and years of the movies that has the top 3 highest rating star? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the names and years released for the movies with the top 3 highest ratings? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | 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. | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | For each director, what are the titles and ratings for all the movies they reviewed? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | Find the title and star rating of the movie that got the least rating star for each reviewer. | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | For each reviewer id, what is the title and rating for the movie with the smallest rating? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | Find the title and score of the movie with the lowest rating among all movies directed by each director. | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | For each director, what is the title and score of their most poorly rated movie? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What is the name of the movie that is rated by most of times? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What is the name of the movie that has been reviewed the most? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the titles of all movies that have rating star is between 3 and 5? | SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars BETWEEN 3 AND 5 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the titles of all movies that have between 3 and 5 stars? | SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars BETWEEN 3 AND 5 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | Find the names of reviewers who had given higher than 3 star ratings. | SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars > 3 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the names of the reviewers who have rated a movie more than 3 stars before? | SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars > 3 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | Find the average rating star for each movie that are not reviewed by Brittany Harris. | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What is the average rating for each movie that has never been reviewed by Brittany Harris? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the ids of the movies that are not reviewed by Brittany Harris. | 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" | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the ids of all moviest hat have not been reviewed by Britanny Harris? | 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" | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | Find the average rating star for each movie that received at least 2 ratings. | SELECT mID , avg(stars) FROM Rating GROUP BY mID HAVING count(*) >= 2 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | For each movie that received more than 3 reviews, what is the average rating? | SELECT mID , avg(stars) FROM Rating GROUP BY mID HAVING count(*) >= 2 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | find the ids of reviewers who did not give 4 star. | SELECT rID FROM Rating EXCEPT SELECT rID FROM Rating WHERE stars = 4 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the ids of all reviewers who did not give 4 stars? | SELECT rID FROM Rating EXCEPT SELECT rID FROM Rating WHERE stars = 4 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | Find the ids of reviewers who didn't only give 4 star. | SELECT rID FROM Rating WHERE stars != 4 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the ids of all reviewers who have not given 4 stars at least once? | SELECT rID FROM Rating WHERE stars != 4 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are names of the movies that are either made after 2000 or reviewed by Brittany Harris? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the names of all movies that were made after 2000 or reviewed by Brittany Harris? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are names of the movies that are either made before 1980 or directed by James Cameron? | SELECT title FROM Movie WHERE director = "James Cameron" OR YEAR < 1980 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the names of all movies made before 1980 or had James Cameron as the director? | SELECT title FROM Movie WHERE director = "James Cameron" OR YEAR < 1980 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the names of reviewers who had rated 3 star and 4 star? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the names of all reviewers that have given 3 or 4 stars for reviews? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the names of movies that get 3 star and 4 star? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
movie_1 | What are the names of all movies that received 3 or 4 stars? | 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 | CREATE TABLE Movie(
mID int primary key,
title text,
year int,
director text
)
3 rows from Movie table:
mID title year director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
CREATE TABLE Reviewer(
rID int primary key,
name text)
3 rows from Reviewer table:
rID name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
CREATE TABLE Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
)
3 rows from Rating table:
rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 None
|
county_public_safety | How many counties are there? | SELECT count(*) FROM 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Count the number of countries. | SELECT count(*) FROM 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | List the names of counties in descending order of population. | SELECT Name FROM county_public_safety ORDER BY Population DESC | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the names of the counties of public safety, ordered by population descending? | SELECT Name FROM county_public_safety ORDER BY Population DESC | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | List the distinct police forces of counties whose location is not on east side. | SELECT DISTINCT Police_force FROM county_public_safety WHERE LOCATION != "East" | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the different police forces of counties that are not located in the East? | SELECT DISTINCT Police_force FROM county_public_safety WHERE LOCATION != "East" | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the minimum and maximum crime rate of counties? | SELECT min(Crime_rate) , max(Crime_rate) FROM 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Return the minimum and maximum crime rates across all counties. | SELECT min(Crime_rate) , max(Crime_rate) FROM 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Show the crime rates of counties in ascending order of number of police officers. | SELECT Crime_rate FROM county_public_safety ORDER BY Police_officers ASC | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the crime rates of counties sorted by number of offices ascending? | SELECT Crime_rate FROM county_public_safety ORDER BY Police_officers ASC | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the names of cities in ascending alphabetical order? | SELECT Name FROM city ORDER BY Name ASC | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Return the names of cities, ordered alphabetically. | SELECT Name FROM city ORDER BY Name ASC | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the percentage of hispanics in cities with the black percentage higher than 10? | SELECT Hispanic FROM city WHERE Black > 10 | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Return the hispanic percentage for cities in which the black percentage is greater than 10. | SELECT Hispanic FROM city WHERE Black > 10 | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | List the name of the county with the largest population. | SELECT Name FROM county_public_safety ORDER BY Population DESC LIMIT 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What is the name of the county with the greatest population? | SELECT Name FROM county_public_safety ORDER BY Population DESC LIMIT 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | List the names of the city with the top 5 white percentages. | SELECT Name FROM city ORDER BY White DESC LIMIT 5 | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the names of the five cities with the greatest proportion of white people? | SELECT Name FROM city ORDER BY White DESC LIMIT 5 | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Show names of cities and names of counties they are in. | SELECT T1.Name , T2.Name FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the names of cities, as well as the names of the counties they correspond to? | SELECT T1.Name , T2.Name FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Show white percentages of cities and the crime rates of counties they are in. | SELECT T1.White , T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the white percentages of cities, and the corresponding crime rates of the counties they correspond to? | SELECT T1.White , T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Show the name of cities in the county that has the largest number of police officers. | SELECT name FROM city WHERE county_ID = (SELECT county_ID FROM county_public_safety ORDER BY Police_officers DESC LIMIT 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the names of cities that are in the county with the most police officers? | SELECT name FROM city WHERE county_ID = (SELECT county_ID FROM county_public_safety ORDER BY Police_officers DESC LIMIT 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Show the number of cities in counties that have a population more than 20000. | SELECT count(*) FROM city WHERE county_ID IN (SELECT county_ID FROM county_public_safety WHERE population > 20000) | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | How many cities are in counties that have populations of over 20000? | SELECT count(*) FROM city WHERE county_ID IN (SELECT county_ID FROM county_public_safety WHERE population > 20000) | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Show the crime rate of counties with a city having white percentage more than 90. | 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 | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the crime rates of counties that contain cities that have white percentages of over 90? | 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 | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Please show the police forces and the number of counties with each police force. | SELECT Police_force , COUNT(*) FROM county_public_safety GROUP BY Police_force | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | How many counties correspond to each police force? | SELECT Police_force , COUNT(*) FROM county_public_safety GROUP BY Police_force | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What is the location shared by most counties? | SELECT LOCATION FROM county_public_safety GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Which location has the most corresponding counties? | SELECT LOCATION FROM county_public_safety GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | List the names of counties that do not have any cities. | SELECT Name FROM county_public_safety WHERE County_ID NOT IN (SELECT County_ID FROM city) | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the names of counties that do not contain any cities? | SELECT Name FROM county_public_safety WHERE County_ID NOT IN (SELECT County_ID FROM city) | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Show the police force shared by counties with location on the east and west. | SELECT Police_force FROM county_public_safety WHERE LOCATION = "East" INTERSECT SELECT Police_force FROM county_public_safety WHERE LOCATION = "West" | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Which police forces operate in both counties that are located in the East and in the West? | SELECT Police_force FROM county_public_safety WHERE LOCATION = "East" INTERSECT SELECT Police_force FROM county_public_safety WHERE LOCATION = "West" | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Show the names of cities in counties that have a crime rate less than 100. | SELECT name FROM city WHERE county_id IN (SELECT county_id FROM county_public_safety WHERE Crime_rate < 100) | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the names of cities that are in counties that have a crime rate below 100? | SELECT name FROM city WHERE county_id IN (SELECT county_id FROM county_public_safety WHERE Crime_rate < 100) | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | Show the case burden of counties in descending order of population. | SELECT Case_burden FROM county_public_safety ORDER BY Population DESC | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
county_public_safety | What are the case burdens of counties, ordered descending by population? | SELECT Case_burden FROM county_public_safety ORDER BY Population DESC | 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")
)
3 rows from county_public_safety table:
County_ID Name Population Police_officers Residents_per_officer Case_burden Crime_rate Police_force Location
1 Abbotsford 128165 187 685 81 118.0 Abbotsford Police Department East
2 Burnaby 204320 253 808 100 123.0 RCMP East
3 Campbell River 30810 40 770 137 178.0 RCMP West
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")
)
3 rows from city table:
City_ID County_ID Name White Black Amerindian Asian Multiracial Hispanic
1 1 Adjuntas 93.1 3.1 0.3 0.0 3.4 99.6
2 1 Aguada 86.6 5.3 0.3 0.1 7.7 99.4
3 1 Aguadilla 83.0 7.4 0.3 0.2 8.2 98.5
|
inn_1 | Find the names of all modern rooms with a base price below $160 and two beds. | SELECT roomName FROM Rooms WHERE basePrice < 160 AND beds = 2 AND decor = 'modern'; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | What are the names of modern rooms that have a base price lower than $160 and two beds. | SELECT roomName FROM Rooms WHERE basePrice < 160 AND beds = 2 AND decor = 'modern'; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Find all the rooms that have a price higher than 160 and can accommodate more than 2 people. Report room names and ids. | SELECT roomName , RoomId FROM Rooms WHERE basePrice > 160 AND maxOccupancy > 2; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | What are the room names and ids of all the rooms that cost more than 160 and can accommodate more than two people. | SELECT roomName , RoomId FROM Rooms WHERE basePrice > 160 AND maxOccupancy > 2; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Find the most popular room in the hotel. The most popular room is the room that had seen the largest number of reservations. | 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; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Which room has the largest number of reservations? | 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; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | How many kids stay in the rooms reserved by ROY SWEAZY? | SELECT kids FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY"; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Find the number of kids staying in the rooms reserved by a person called ROY SWEAZ. | SELECT kids FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY"; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | How many times does ROY SWEAZY has reserved a room. | SELECT count(*) FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY"; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Find the number of times ROY SWEAZY has reserved a room. | SELECT count(*) FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY"; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Which room has the highest rate? List the room's full name, rate, check in and check out date. | 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; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Return the name, rate, check in and check out date for the room with the highest rate. | 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; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | How many adults stay in the room CONRAD SELBIG checked in on Oct 23, 2010? | SELECT Adults FROM Reservations WHERE CheckIn = "2010-10-23" AND FirstName = "CONRAD" AND LastName = "SELBIG"; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Find the number of adults for the room reserved and checked in by CONRAD SELBIG on Oct 23, 2010. | SELECT Adults FROM Reservations WHERE CheckIn = "2010-10-23" AND FirstName = "CONRAD" AND LastName = "SELBIG"; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | How many kids stay in the room DAMIEN TRACHSEL checked in on Sep 21, 2010? | SELECT Kids FROM Reservations WHERE CheckIn = "2010-09-21" AND FirstName = "DAMIEN" AND LastName = "TRACHSEL"; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Return the number of kids for the room reserved and checked in by DAMIEN TRACHSEL on Sep 21, 2010. | SELECT Kids FROM Reservations WHERE CheckIn = "2010-09-21" AND FirstName = "DAMIEN" AND LastName = "TRACHSEL"; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | How many king beds are there? | SELECT sum(beds) FROM Rooms WHERE bedtype = 'King'; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Find the total number of king beds available. | SELECT sum(beds) FROM Rooms WHERE bedtype = 'King'; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | List the names and decor of rooms that have a king bed. Sort the list by their price. | SELECT roomName , decor FROM Rooms WHERE bedtype = 'King' ORDER BY basePrice; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | What are the names and decor of rooms with a king bed? Sort them by their price | SELECT roomName , decor FROM Rooms WHERE bedtype = 'King' ORDER BY basePrice; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Which room has cheapest base price? List the room's name and the base price. | SELECT roomName , basePrice FROM Rooms ORDER BY basePrice ASC LIMIT 1; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | What are the room name and base price of the room with the lowest base price? | SELECT roomName , basePrice FROM Rooms ORDER BY basePrice ASC LIMIT 1; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | What is the decor of room Recluse and defiance? | SELECT decor FROM Rooms WHERE roomName = "Recluse and defiance"; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | Return the decor of the room named "Recluse and defiance". | SELECT decor FROM Rooms WHERE roomName = "Recluse and defiance"; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | What is the average base price of different bed type? List bed type and average base price. | SELECT bedType , avg(basePrice) FROM Rooms GROUP BY bedType; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | For each bed type, find the average base price of different bed type. | SELECT bedType , avg(basePrice) FROM Rooms GROUP BY bedType; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | What is the total number of people who could stay in the modern rooms in this inn? | SELECT sum(maxOccupancy) FROM Rooms WHERE decor = 'modern'; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
inn_1 | How many people in total can stay in the modern rooms of this inn? | SELECT sum(maxOccupancy) FROM Rooms WHERE decor = 'modern'; | CREATE TABLE "Rooms" (
"RoomId" TEXT PRIMARY KEY,
"roomName" TEXT,
"beds" INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
"decor" TEXT
)
3 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
AOB Abscond or bolster 2 Queen 4 175 traditional
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)
)
3 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
10449 RND 30-SEP-10 01-OCT-10 150.0 KLESS NELSON 1 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.