SQL
stringlengths
18
577
question
stringlengths
317
11.5k
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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. For each reviewer id, what is the title and rating for the movie with the smallest rating?
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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. For each director, what is the title and score of their most poorly rated movie?
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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the name of the movie that has been reviewed the most?
SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars BETWEEN 3 AND 5
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the titles of all movies that have between 3 and 5 stars?
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars > 3
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the names of the reviewers who have rated a movie more than 3 stars before?
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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the average rating for each movie that has never been 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"
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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"
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the ids of all moviest hat have not been reviewed by Britanny Harris?
SELECT mID , avg(stars) FROM Rating GROUP BY mID HAVING count(*) >= 2
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. For each movie that received more than 3 reviews, what is the average rating?
SELECT rID FROM Rating EXCEPT SELECT rID FROM Rating WHERE stars = 4
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. find the ids of reviewers who did not give 4 star.
SELECT rID FROM Rating EXCEPT SELECT rID FROM Rating WHERE stars = 4
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the ids of all reviewers who did not give 4 stars?
SELECT rID FROM Rating WHERE stars != 4
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the ids of reviewers who didn't only give 4 star.
SELECT rID FROM Rating WHERE stars != 4
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the ids of all reviewers who have not given 4 stars at least once?
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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the names of all movies that were made after 2000 or reviewed by Brittany Harris?
SELECT title FROM Movie WHERE director = "James Cameron" OR YEAR < 1980
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the names of all movies made before 1980 or had James Cameron as the director?
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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the names of all reviewers that have given 3 or 4 stars for reviews?
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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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
Given the Table movie having columns as mID has datatype number, title has datatype text, year has datatype number, director has datatype text which has mID and Given the Table reviewer having columns as rID has datatype number, name has datatype text which has rID and Given the Table rating having columns as rID has datatype number, mID has datatype number, stars has datatype number, ratingDate has datatype time which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the names of all movies that received 3 or 4 stars?
SELECT count(*) FROM county_public_safety
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. How many counties are there?
SELECT count(*) FROM county_public_safety
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. Count the number of countries.
SELECT Name FROM county_public_safety ORDER BY Population DESC
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. List the names of counties in descending order of population.
SELECT Name FROM county_public_safety ORDER BY Population DESC
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the names of the counties of public safety, ordered by population descending?
SELECT DISTINCT Police_force FROM county_public_safety WHERE LOCATION != "East"
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. 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"
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the different police forces of counties that are not located in the East?
SELECT min(Crime_rate) , max(Crime_rate) FROM county_public_safety
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the minimum and maximum crime rate of counties?
SELECT min(Crime_rate) , max(Crime_rate) FROM county_public_safety
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. Return the minimum and maximum crime rates across all counties.
SELECT Crime_rate FROM county_public_safety ORDER BY Police_officers ASC
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. 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
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the crime rates of counties sorted by number of offices ascending?
SELECT Name FROM city ORDER BY Name ASC
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the names of cities in ascending alphabetical order?
SELECT Name FROM city ORDER BY Name ASC
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. Return the names of cities, ordered alphabetically.
SELECT Hispanic FROM city WHERE Black > 10
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the percentage of hispanics in cities with the black percentage higher than 10?
SELECT Hispanic FROM city WHERE Black > 10
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. Return the hispanic percentage for cities in which the black percentage is greater than 10.
SELECT Name FROM county_public_safety ORDER BY Population DESC LIMIT 1
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. List the name of the county with the largest population.
SELECT Name FROM county_public_safety ORDER BY Population DESC LIMIT 1
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What is the name of the county with the greatest population?
SELECT Name FROM city ORDER BY White DESC LIMIT 5
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. List the names of the city with the top 5 white percentages.
SELECT Name FROM city ORDER BY White DESC LIMIT 5
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the names of the five cities with the greatest proportion of white people?
SELECT T1.Name , T2.Name FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. 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
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the names of cities, as well as the names 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
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. 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
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the white percentages of cities, and the corresponding crime rates of the counties they correspond to?
SELECT name FROM city WHERE county_ID = (SELECT county_ID FROM county_public_safety ORDER BY Police_officers DESC LIMIT 1)
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. 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)
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the names of cities that are in the county with the most police officers?
SELECT count(*) FROM city WHERE county_ID IN (SELECT county_ID FROM county_public_safety WHERE population > 20000)
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. 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)
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. How many cities are in counties that have populations of over 20000?
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
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. 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
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the crime rates of counties that contain cities that have white percentages of over 90?
SELECT Police_force , COUNT(*) FROM county_public_safety GROUP BY Police_force
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. 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
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. How many counties correspond to each police force?
SELECT LOCATION FROM county_public_safety GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What is the location shared by most counties?
SELECT LOCATION FROM county_public_safety GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. Which location has the most corresponding counties?
SELECT Name FROM county_public_safety WHERE County_ID NOT IN (SELECT County_ID FROM city)
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. 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)
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the names of counties that do not contain any cities?
SELECT Police_force FROM county_public_safety WHERE LOCATION = "East" INTERSECT SELECT Police_force FROM county_public_safety WHERE LOCATION = "West"
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. 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"
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. Which police forces operate in both counties that are located in the East and in the West?
SELECT name FROM city WHERE county_id IN (SELECT county_id FROM county_public_safety WHERE Crime_rate < 100)
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. 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)
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the names of cities that are in counties that have a crime rate below 100?
SELECT Case_burden FROM county_public_safety ORDER BY Population DESC
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. Show the case burden of counties in descending order of population.
SELECT Case_burden FROM county_public_safety ORDER BY Population DESC
Given the Table county public safety having columns as County_ID has datatype number, Name has datatype text, Population has datatype number, Police_officers has datatype number, Residents_per_officer has datatype number, Case_burden has datatype number, Crime_rate has datatype number, Police_force has datatype text, Location has datatype text which has County_ID and Given the Table city having columns as City_ID has datatype number, County_ID has datatype number, Name has datatype text, White has datatype number, Black has datatype number, Amerindian has datatype number, Asian has datatype number, Multiracial has datatype number, Hispanic has datatype number which has City_ID. Answer the question by writing the appropriate SQL code. What are the case burdens of counties, ordered descending by population?
SELECT roomName FROM Rooms WHERE basePrice < 160 AND beds = 2 AND decor = 'modern';
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. 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';
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. What are the names of modern rooms that have a base price lower than $160 and two beds.
SELECT roomName , RoomId FROM Rooms WHERE basePrice > 160 AND maxOccupancy > 2;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. 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;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. What are the room names and ids of all the rooms that cost more than 160 and can accommodate more than two people.
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;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. 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;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. Which room has the largest number of reservations?
SELECT kids FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY";
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. How many kids stay in the rooms reserved by ROY SWEAZY?
SELECT kids FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY";
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. Find the number of kids staying in the rooms reserved by a person called ROY SWEAZ.
SELECT count(*) FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY";
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. How many times does ROY SWEAZY has reserved a room.
SELECT count(*) FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY";
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. Find the number of times ROY SWEAZY has reserved a room.
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;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. 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;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. Return the name, rate, check in and check out date for the room with the highest rate.
SELECT Adults FROM Reservations WHERE CheckIn = "2010-10-23" AND FirstName = "CONRAD" AND LastName = "SELBIG";
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. 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";
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. Find the number of adults for the room reserved and checked in by CONRAD SELBIG on Oct 23, 2010.
SELECT Kids FROM Reservations WHERE CheckIn = "2010-09-21" AND FirstName = "DAMIEN" AND LastName = "TRACHSEL";
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. 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";
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. Return the number of kids for the room reserved and checked in by DAMIEN TRACHSEL on Sep 21, 2010.
SELECT sum(beds) FROM Rooms WHERE bedtype = 'King';
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. How many king beds are there?
SELECT sum(beds) FROM Rooms WHERE bedtype = 'King';
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. Find the total number of king beds available.
SELECT roomName , decor FROM Rooms WHERE bedtype = 'King' ORDER BY basePrice;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. 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;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. What are the names and decor of rooms with a king bed? Sort them by their price
SELECT roomName , basePrice FROM Rooms ORDER BY basePrice ASC LIMIT 1;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. 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;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. What are the room name and base price of the room with the lowest base price?
SELECT decor FROM Rooms WHERE roomName = "Recluse and defiance";
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. What is the decor of room Recluse and defiance?
SELECT decor FROM Rooms WHERE roomName = "Recluse and defiance";
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. Return the decor of the room named "Recluse and defiance".
SELECT bedType , avg(basePrice) FROM Rooms GROUP BY bedType;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. 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;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. For each bed type, find the average base price of different bed type.
SELECT sum(maxOccupancy) FROM Rooms WHERE decor = 'modern';
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. 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';
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. How many people in total can stay in the modern rooms of this inn?
SELECT T2.decor FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T2.decor ORDER BY count(T2.decor) ASC LIMIT 1;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. What kind of decor has the least number of reservations?
SELECT T2.decor FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T2.decor ORDER BY count(T2.decor) ASC LIMIT 1;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. What is the least popular kind of decor?
SELECT count(*) FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId WHERE T2.maxOccupancy = T1.Adults + T1.Kids;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. List how many times the number of people in the room reached the maximum occupancy of the room. The number of people include adults and kids.
SELECT count(*) FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId WHERE T2.maxOccupancy = T1.Adults + T1.Kids;
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. How many times the number of adults and kids staying in a room reached the maximum capacity of the room?
SELECT T1.firstname , T1.lastname FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId WHERE T1.Rate - T2.basePrice > 0
Given the Table rooms having columns as RoomId has datatype text, roomName has datatype text, beds has datatype number, bedType has datatype text, maxOccupancy has datatype number, basePrice has datatype number, decor has datatype text which has RoomId and Given the Table reservations having columns as Code has datatype number, Room has datatype text, CheckIn has datatype text, CheckOut has datatype text, Rate has datatype number, LastName has datatype text, FirstName has datatype text, Adults has datatype number, Kids has datatype number which has Code. Answer the question by writing the appropriate SQL code. Find the first and last names of people who payed more than the rooms' base prices.