question
stringlengths
19
224
context
stringlengths
30
355
answer
stringlengths
20
557
input
stringlengths
138
630
output
stringlengths
20
557
List each donator name and the amount of endowment in descending order of the amount of endowment.
CREATE TABLE endowment (donator_name VARCHAR, amount INTEGER)
SELECT donator_name, SUM(amount) FROM endowment GROUP BY donator_name ORDER BY SUM(amount) DESC
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE endowment (donator_name VARCHAR, amount INTEGER) ### question:List each donator name and the amount of endowment in descending order of the amount of endowment.
SELECT donator_name, SUM(amount) FROM endowment GROUP BY donator_name ORDER BY SUM(amount) DESC
List the names of the schools without any endowment.
CREATE TABLE endowment (school_name VARCHAR, school_id VARCHAR); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)
SELECT school_name FROM school WHERE NOT school_id IN (SELECT school_id FROM endowment)
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE endowment (school_name VARCHAR, school_id VARCHAR); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR) ### question:List the names of the schools without any endowment.
SELECT school_name FROM school WHERE NOT school_id IN (SELECT school_id FROM endowment)
List all the names of schools with an endowment amount smaller than or equal to 10.
CREATE TABLE school (school_name VARCHAR, school_id VARCHAR); CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)
SELECT T2.school_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id GROUP BY T1.school_id HAVING SUM(T1.amount) <= 10
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE school (school_name VARCHAR, school_id VARCHAR); CREATE TABLE endowment (school_id VARCHAR, amount INTEGER) ### question:List all the names of schools with an endowment amount smaller than or equal to 10.
SELECT T2.school_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id GROUP BY T1.school_id HAVING SUM(T1.amount) <= 10
Show the names of donors who donated to both school "Glenn" and "Triton."
CREATE TABLE school (school_id VARCHAR, school_name VARCHAR); CREATE TABLE endowment (donator_name VARCHAR, school_id VARCHAR)
SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn' INTERSECT SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Triton'
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE school (school_id VARCHAR, school_name VARCHAR); CREATE TABLE endowment (donator_name VARCHAR, school_id VARCHAR) ### question:Show the names of donors who donated to both school "Glenn" and "Triton."
SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn' INTERSECT SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Triton'
Show the names of all the donors except those whose donation amount less than 9.
CREATE TABLE endowment (donator_name VARCHAR, amount INTEGER)
SELECT donator_name FROM endowment EXCEPT SELECT donator_name FROM endowment WHERE amount < 9
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE endowment (donator_name VARCHAR, amount INTEGER) ### question:Show the names of all the donors except those whose donation amount less than 9.
SELECT donator_name FROM endowment EXCEPT SELECT donator_name FROM endowment WHERE amount < 9
List the amount and donor name for the largest amount of donation.
CREATE TABLE endowment (amount VARCHAR, donator_name VARCHAR)
SELECT amount, donator_name FROM endowment ORDER BY amount DESC LIMIT 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE endowment (amount VARCHAR, donator_name VARCHAR) ### question:List the amount and donor name for the largest amount of donation.
SELECT amount, donator_name FROM endowment ORDER BY amount DESC LIMIT 1
How many budgets are above 3000 in year 2001 or before?
CREATE TABLE budget (budgeted VARCHAR, YEAR VARCHAR)
SELECT COUNT(*) FROM budget WHERE budgeted > 3000 AND YEAR <= 2001
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE budget (budgeted VARCHAR, YEAR VARCHAR) ### question:How many budgets are above 3000 in year 2001 or before?
SELECT COUNT(*) FROM budget WHERE budgeted > 3000 AND YEAR <= 2001
Show each school name, its budgeted amount, and invested amount in year 2002 or after.
CREATE TABLE budget (budgeted VARCHAR, invested VARCHAR, school_id VARCHAR, year VARCHAR); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)
SELECT T2.school_name, T1.budgeted, T1.invested FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.year >= 2002
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE budget (budgeted VARCHAR, invested VARCHAR, school_id VARCHAR, year VARCHAR); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR) ### question:Show each school name, its budgeted amount, and invested amount in year 2002 or after.
SELECT T2.school_name, T1.budgeted, T1.invested FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.year >= 2002
Show all donor names.
CREATE TABLE endowment (donator_name VARCHAR)
SELECT DISTINCT donator_name FROM endowment
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE endowment (donator_name VARCHAR) ### question:Show all donor names.
SELECT DISTINCT donator_name FROM endowment
How many budget record has a budget amount smaller than the invested amount?
CREATE TABLE budget (budgeted INTEGER, invested VARCHAR)
SELECT COUNT(*) FROM budget WHERE budgeted < invested
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE budget (budgeted INTEGER, invested VARCHAR) ### question:How many budget record has a budget amount smaller than the invested amount?
SELECT COUNT(*) FROM budget WHERE budgeted < invested
What is the total budget amount for school "Glenn" in all years?
CREATE TABLE budget (budgeted INTEGER, school_id VARCHAR); CREATE TABLE school (school_id VARCHAR, school_name VARCHAR)
SELECT SUM(T1.budgeted) FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn'
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE budget (budgeted INTEGER, school_id VARCHAR); CREATE TABLE school (school_id VARCHAR, school_name VARCHAR) ### question:What is the total budget amount for school "Glenn" in all years?
SELECT SUM(T1.budgeted) FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn'
Show the names of schools with a total budget amount greater than 100 or a total endowment greater than 10.
CREATE TABLE endowment (school_id VARCHAR, amount INTEGER); CREATE TABLE budget (school_id VARCHAR, budgeted INTEGER); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)
SELECT T2.school_name FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id JOIN endowment AS T3 ON T2.school_id = T3.school_id GROUP BY T2.school_name HAVING SUM(T1.budgeted) > 100 OR SUM(T3.amount) > 10
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE endowment (school_id VARCHAR, amount INTEGER); CREATE TABLE budget (school_id VARCHAR, budgeted INTEGER); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR) ### question:Show the names of schools with a total budget amount greater than 100 or a total endowment greater than 10.
SELECT T2.school_name FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id JOIN endowment AS T3 ON T2.school_id = T3.school_id GROUP BY T2.school_name HAVING SUM(T1.budgeted) > 100 OR SUM(T3.amount) > 10
Find the names of schools that have more than one donator with donation amount above 8.5.
CREATE TABLE school (School_name VARCHAR, school_id VARCHAR); CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)
SELECT T2.School_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.amount > 8.5 GROUP BY T1.school_id HAVING COUNT(*) > 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE school (School_name VARCHAR, school_id VARCHAR); CREATE TABLE endowment (school_id VARCHAR, amount INTEGER) ### question:Find the names of schools that have more than one donator with donation amount above 8.5.
SELECT T2.School_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.amount > 8.5 GROUP BY T1.school_id HAVING COUNT(*) > 1
Find the number of schools that have more than one donator whose donation amount is less than 8.5.
CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)
SELECT COUNT(*) FROM (SELECT * FROM endowment WHERE amount > 8.5 GROUP BY school_id HAVING COUNT(*) > 1)
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE endowment (school_id VARCHAR, amount INTEGER) ### question:Find the number of schools that have more than one donator whose donation amount is less than 8.5.
SELECT COUNT(*) FROM (SELECT * FROM endowment WHERE amount > 8.5 GROUP BY school_id HAVING COUNT(*) > 1)
List the name, IHSAA Football Class, and Mascot of the schools that have more than 6000 of budgeted amount or were founded before 2003, in the order of percent of total invested budget and total budgeted budget.
CREATE TABLE school (School_name VARCHAR, Mascot VARCHAR, IHSAA_Football_Class VARCHAR, school_id VARCHAR); CREATE TABLE budget (school_id VARCHAR, total_budget_percent_invested VARCHAR, total_budget_percent_budgeted VARCHAR)
SELECT T1.School_name, T1.Mascot, T1.IHSAA_Football_Class FROM school AS T1 JOIN budget AS T2 ON T1.school_id = T2.school_id WHERE Budgeted > 6000 OR YEAR < 2003 ORDER BY T2.total_budget_percent_invested, T2.total_budget_percent_budgeted
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE school (School_name VARCHAR, Mascot VARCHAR, IHSAA_Football_Class VARCHAR, school_id VARCHAR); CREATE TABLE budget (school_id VARCHAR, total_budget_percent_invested VARCHAR, total_budget_percent_budgeted VARCHAR) ### question:List the name, IHSAA Football Class, and Mascot of the schools that have more than 6000 of budgeted amount or were founded before 2003, in the order of percent of total invested budget and total budgeted budget.
SELECT T1.School_name, T1.Mascot, T1.IHSAA_Football_Class FROM school AS T1 JOIN budget AS T2 ON T1.school_id = T2.school_id WHERE Budgeted > 6000 OR YEAR < 2003 ORDER BY T2.total_budget_percent_invested, T2.total_budget_percent_budgeted
How many buildings are there?
CREATE TABLE building (Id VARCHAR)
SELECT COUNT(*) FROM building
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE building (Id VARCHAR) ### question:How many buildings are there?
SELECT COUNT(*) FROM building
Show the name, street address, and number of floors for all buildings ordered by the number of floors.
CREATE TABLE building (name VARCHAR, street_address VARCHAR, floors VARCHAR)
SELECT name, street_address, floors FROM building ORDER BY floors
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE building (name VARCHAR, street_address VARCHAR, floors VARCHAR) ### question:Show the name, street address, and number of floors for all buildings ordered by the number of floors.
SELECT name, street_address, floors FROM building ORDER BY floors
What is the name of the tallest building?
CREATE TABLE building (name VARCHAR, height_feet VARCHAR)
SELECT name FROM building ORDER BY height_feet DESC LIMIT 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE building (name VARCHAR, height_feet VARCHAR) ### question:What is the name of the tallest building?
SELECT name FROM building ORDER BY height_feet DESC LIMIT 1
What are the average, maximum, and minimum number of floors for all buildings?
CREATE TABLE building (floors INTEGER)
SELECT AVG(floors), MAX(floors), MIN(floors) FROM building
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE building (floors INTEGER) ### question:What are the average, maximum, and minimum number of floors for all buildings?
SELECT AVG(floors), MAX(floors), MIN(floors) FROM building
Show the number of buildings with a height above the average or a number of floors above the average.
CREATE TABLE building (height_feet INTEGER, floors INTEGER)
SELECT COUNT(*) FROM building WHERE height_feet > (SELECT AVG(height_feet) FROM building) OR floors > (SELECT AVG(floors) FROM building)
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE building (height_feet INTEGER, floors INTEGER) ### question:Show the number of buildings with a height above the average or a number of floors above the average.
SELECT COUNT(*) FROM building WHERE height_feet > (SELECT AVG(height_feet) FROM building) OR floors > (SELECT AVG(floors) FROM building)
List the names of buildings with at least 200 feet of height and with at least 20 floors.
CREATE TABLE building (name VARCHAR, height_feet VARCHAR, floors VARCHAR)
SELECT name FROM building WHERE height_feet >= 200 AND floors >= 20
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE building (name VARCHAR, height_feet VARCHAR, floors VARCHAR) ### question:List the names of buildings with at least 200 feet of height and with at least 20 floors.
SELECT name FROM building WHERE height_feet >= 200 AND floors >= 20
Show the names and locations of institutions that are founded after 1990 and have the type "Private".
CREATE TABLE institution (institution VARCHAR, LOCATION VARCHAR, founded VARCHAR, TYPE VARCHAR)
SELECT institution, LOCATION FROM institution WHERE founded > 1990 AND TYPE = 'Private'
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE institution (institution VARCHAR, LOCATION VARCHAR, founded VARCHAR, TYPE VARCHAR) ### question:Show the names and locations of institutions that are founded after 1990 and have the type "Private".
SELECT institution, LOCATION FROM institution WHERE founded > 1990 AND TYPE = 'Private'
Show institution types, along with the number of institutions and total enrollment for each type.
CREATE TABLE institution (TYPE VARCHAR, enrollment INTEGER)
SELECT TYPE, COUNT(*), SUM(enrollment) FROM institution GROUP BY TYPE
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE institution (TYPE VARCHAR, enrollment INTEGER) ### question:Show institution types, along with the number of institutions and total enrollment for each type.
SELECT TYPE, COUNT(*), SUM(enrollment) FROM institution GROUP BY TYPE
Show the institution type with the largest number of institutions.
CREATE TABLE institution (TYPE VARCHAR)
SELECT TYPE FROM institution GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE institution (TYPE VARCHAR) ### question:Show the institution type with the largest number of institutions.
SELECT TYPE FROM institution GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1
Show the institution type with an institution founded after 1990 and an institution with at least 1000 enrollment.
CREATE TABLE institution (TYPE VARCHAR, founded VARCHAR, enrollment VARCHAR)
SELECT TYPE FROM institution WHERE founded > 1990 AND enrollment >= 1000
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE institution (TYPE VARCHAR, founded VARCHAR, enrollment VARCHAR) ### question:Show the institution type with an institution founded after 1990 and an institution with at least 1000 enrollment.
SELECT TYPE FROM institution WHERE founded > 1990 AND enrollment >= 1000
Show the name of buildings that do not have any institution.
CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE institution (name VARCHAR, building_id VARCHAR)
SELECT name FROM building WHERE NOT building_id IN (SELECT building_id FROM institution)
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE institution (name VARCHAR, building_id VARCHAR) ### question:Show the name of buildings that do not have any institution.
SELECT name FROM building WHERE NOT building_id IN (SELECT building_id FROM institution)
Show the names of buildings except for those having an institution founded in 2003.
CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE building (name VARCHAR); CREATE TABLE institution (building_id VARCHAR, founded VARCHAR)
SELECT name FROM building EXCEPT SELECT T1.name FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded = 2003
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE building (name VARCHAR); CREATE TABLE institution (building_id VARCHAR, founded VARCHAR) ### question:Show the names of buildings except for those having an institution founded in 2003.
SELECT name FROM building EXCEPT SELECT T1.name FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded = 2003
For each building, show the name of the building and the number of institutions in it.
CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE institution (building_id VARCHAR)
SELECT T1.name, COUNT(*) FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id GROUP BY T1.building_id
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE institution (building_id VARCHAR) ### question:For each building, show the name of the building and the number of institutions in it.
SELECT T1.name, COUNT(*) FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id GROUP BY T1.building_id
Show the names and heights of buildings with at least two institutions founded after 1880.
CREATE TABLE building (name VARCHAR, height_feet VARCHAR, building_id VARCHAR); CREATE TABLE institution (building_id VARCHAR, founded INTEGER)
SELECT T1.name, T1.height_feet FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded > 1880 GROUP BY T1.building_id HAVING COUNT(*) >= 2
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE building (name VARCHAR, height_feet VARCHAR, building_id VARCHAR); CREATE TABLE institution (building_id VARCHAR, founded INTEGER) ### question:Show the names and heights of buildings with at least two institutions founded after 1880.
SELECT T1.name, T1.height_feet FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded > 1880 GROUP BY T1.building_id HAVING COUNT(*) >= 2
Show all the distinct institution types.
CREATE TABLE institution (TYPE VARCHAR)
SELECT DISTINCT TYPE FROM institution
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE institution (TYPE VARCHAR) ### question:Show all the distinct institution types.
SELECT DISTINCT TYPE FROM institution
Show institution names along with the number of proteins for each institution.
CREATE TABLE institution (institution VARCHAR, institution_id VARCHAR); CREATE TABLE protein (institution_id VARCHAR)
SELECT T1.institution, COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id GROUP BY T1.institution_id
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE institution (institution VARCHAR, institution_id VARCHAR); CREATE TABLE protein (institution_id VARCHAR) ### question:Show institution names along with the number of proteins for each institution.
SELECT T1.institution, COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id GROUP BY T1.institution_id
How many proteins are associated with an institution founded after 1880 or an institution with type "Private"?
CREATE TABLE institution (institution_id VARCHAR, founded VARCHAR, type VARCHAR); CREATE TABLE protein (institution_id VARCHAR)
SELECT COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id WHERE T1.founded > 1880 OR T1.type = 'Private'
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE institution (institution_id VARCHAR, founded VARCHAR, type VARCHAR); CREATE TABLE protein (institution_id VARCHAR) ### question:How many proteins are associated with an institution founded after 1880 or an institution with type "Private"?
SELECT COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id WHERE T1.founded > 1880 OR T1.type = 'Private'
Show the protein name and the institution name.
CREATE TABLE institution (institution VARCHAR, institution_id VARCHAR); CREATE TABLE protein (protein_name VARCHAR, institution_id VARCHAR)
SELECT T2.protein_name, T1.institution FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE institution (institution VARCHAR, institution_id VARCHAR); CREATE TABLE protein (protein_name VARCHAR, institution_id VARCHAR) ### question:Show the protein name and the institution name.
SELECT T2.protein_name, T1.institution FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id
How many proteins are associated with an institution in a building with at least 20 floors?
CREATE TABLE institution (institution_id VARCHAR, building_id VARCHAR); CREATE TABLE building (building_id VARCHAR, floors VARCHAR); CREATE TABLE protein (institution_id VARCHAR)
SELECT COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id JOIN building AS T3 ON T3.building_id = T1.building_id WHERE T3.floors >= 20
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE institution (institution_id VARCHAR, building_id VARCHAR); CREATE TABLE building (building_id VARCHAR, floors VARCHAR); CREATE TABLE protein (institution_id VARCHAR) ### question:How many proteins are associated with an institution in a building with at least 20 floors?
SELECT COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id JOIN building AS T3 ON T3.building_id = T1.building_id WHERE T3.floors >= 20
How many institutions do not have an associated protein in our record?
CREATE TABLE protein (institution_id VARCHAR); CREATE TABLE institution (institution_id VARCHAR)
SELECT COUNT(*) FROM institution WHERE NOT institution_id IN (SELECT institution_id FROM protein)
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE protein (institution_id VARCHAR); CREATE TABLE institution (institution_id VARCHAR) ### question:How many institutions do not have an associated protein in our record?
SELECT COUNT(*) FROM institution WHERE NOT institution_id IN (SELECT institution_id FROM protein)
Show all the locations where no cinema has capacity over 800.
CREATE TABLE cinema (LOCATION VARCHAR, capacity INTEGER)
SELECT LOCATION FROM cinema EXCEPT SELECT LOCATION FROM cinema WHERE capacity > 800
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (LOCATION VARCHAR, capacity INTEGER) ### question:Show all the locations where no cinema has capacity over 800.
SELECT LOCATION FROM cinema EXCEPT SELECT LOCATION FROM cinema WHERE capacity > 800
Show all the locations where some cinemas were opened in both year 2010 and year 2011.
CREATE TABLE cinema (LOCATION VARCHAR, openning_year VARCHAR)
SELECT LOCATION FROM cinema WHERE openning_year = 2010 INTERSECT SELECT LOCATION FROM cinema WHERE openning_year = 2011
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (LOCATION VARCHAR, openning_year VARCHAR) ### question:Show all the locations where some cinemas were opened in both year 2010 and year 2011.
SELECT LOCATION FROM cinema WHERE openning_year = 2010 INTERSECT SELECT LOCATION FROM cinema WHERE openning_year = 2011
How many cinema do we have?
CREATE TABLE cinema (Id VARCHAR)
SELECT COUNT(*) FROM cinema
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (Id VARCHAR) ### question:How many cinema do we have?
SELECT COUNT(*) FROM cinema
Show name, opening year, and capacity for each cinema.
CREATE TABLE cinema (name VARCHAR, openning_year VARCHAR, capacity VARCHAR)
SELECT name, openning_year, capacity FROM cinema
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (name VARCHAR, openning_year VARCHAR, capacity VARCHAR) ### question:Show name, opening year, and capacity for each cinema.
SELECT name, openning_year, capacity FROM cinema
Show the cinema name and location for cinemas with capacity above average.
CREATE TABLE cinema (name VARCHAR, LOCATION VARCHAR, capacity INTEGER)
SELECT name, LOCATION FROM cinema WHERE capacity > (SELECT AVG(capacity) FROM cinema)
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (name VARCHAR, LOCATION VARCHAR, capacity INTEGER) ### question:Show the cinema name and location for cinemas with capacity above average.
SELECT name, LOCATION FROM cinema WHERE capacity > (SELECT AVG(capacity) FROM cinema)
What are all the locations with a cinema?
CREATE TABLE cinema (LOCATION VARCHAR)
SELECT DISTINCT LOCATION FROM cinema
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (LOCATION VARCHAR) ### question:What are all the locations with a cinema?
SELECT DISTINCT LOCATION FROM cinema
Show all the cinema names and opening years in descending order of opening year.
CREATE TABLE cinema (name VARCHAR, openning_year VARCHAR)
SELECT name, openning_year FROM cinema ORDER BY openning_year DESC
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (name VARCHAR, openning_year VARCHAR) ### question:Show all the cinema names and opening years in descending order of opening year.
SELECT name, openning_year FROM cinema ORDER BY openning_year DESC
What are the name and location of the cinema with the largest capacity?
CREATE TABLE cinema (name VARCHAR, LOCATION VARCHAR, capacity VARCHAR)
SELECT name, LOCATION FROM cinema ORDER BY capacity DESC LIMIT 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (name VARCHAR, LOCATION VARCHAR, capacity VARCHAR) ### question:What are the name and location of the cinema with the largest capacity?
SELECT name, LOCATION FROM cinema ORDER BY capacity DESC LIMIT 1
Show the average, minimum, and maximum capacity for all the cinemas opened in year 2011 or later.
CREATE TABLE cinema (capacity INTEGER, openning_year VARCHAR)
SELECT AVG(capacity), MIN(capacity), MAX(capacity) FROM cinema WHERE openning_year >= 2011
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (capacity INTEGER, openning_year VARCHAR) ### question:Show the average, minimum, and maximum capacity for all the cinemas opened in year 2011 or later.
SELECT AVG(capacity), MIN(capacity), MAX(capacity) FROM cinema WHERE openning_year >= 2011
Show each location and the number of cinemas there.
CREATE TABLE cinema (LOCATION VARCHAR)
SELECT LOCATION, COUNT(*) FROM cinema GROUP BY LOCATION
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (LOCATION VARCHAR) ### question:Show each location and the number of cinemas there.
SELECT LOCATION, COUNT(*) FROM cinema GROUP BY LOCATION
What is the location with the most cinemas opened in year 2010 or later?
CREATE TABLE cinema (LOCATION VARCHAR, openning_year VARCHAR)
SELECT LOCATION FROM cinema WHERE openning_year >= 2010 GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (LOCATION VARCHAR, openning_year VARCHAR) ### question:What is the location with the most cinemas opened in year 2010 or later?
SELECT LOCATION FROM cinema WHERE openning_year >= 2010 GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1
Show all the locations with at least two cinemas with capacity above 300.
CREATE TABLE cinema (LOCATION VARCHAR, capacity INTEGER)
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING COUNT(*) >= 2
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (LOCATION VARCHAR, capacity INTEGER) ### question:Show all the locations with at least two cinemas with capacity above 300.
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING COUNT(*) >= 2
Show the title and director for all films.
CREATE TABLE film (title VARCHAR, directed_by VARCHAR)
SELECT title, directed_by FROM film
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE film (title VARCHAR, directed_by VARCHAR) ### question:Show the title and director for all films.
SELECT title, directed_by FROM film
Show all directors.
CREATE TABLE film (directed_by VARCHAR)
SELECT DISTINCT directed_by FROM film
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE film (directed_by VARCHAR) ### question:Show all directors.
SELECT DISTINCT directed_by FROM film
List all directors along with the number of films directed by each director.
CREATE TABLE film (directed_by VARCHAR)
SELECT directed_by, COUNT(*) FROM film GROUP BY directed_by
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE film (directed_by VARCHAR) ### question:List all directors along with the number of films directed by each director.
SELECT directed_by, COUNT(*) FROM film GROUP BY directed_by
What is total number of show times per dat for each cinema?
CREATE TABLE schedule (show_times_per_day INTEGER, cinema_id VARCHAR); CREATE TABLE cinema (name VARCHAR, cinema_id VARCHAR)
SELECT T2.name, SUM(T1.show_times_per_day) FROM schedule AS T1 JOIN cinema AS T2 ON T1.cinema_id = T2.cinema_id GROUP BY T1.cinema_id
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE schedule (show_times_per_day INTEGER, cinema_id VARCHAR); CREATE TABLE cinema (name VARCHAR, cinema_id VARCHAR) ### question:What is total number of show times per dat for each cinema?
SELECT T2.name, SUM(T1.show_times_per_day) FROM schedule AS T1 JOIN cinema AS T2 ON T1.cinema_id = T2.cinema_id GROUP BY T1.cinema_id
What are the title and maximum price of each film?
CREATE TABLE film (title VARCHAR, film_id VARCHAR); CREATE TABLE schedule (price INTEGER, film_id VARCHAR)
SELECT T2.title, MAX(T1.price) FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE film (title VARCHAR, film_id VARCHAR); CREATE TABLE schedule (price INTEGER, film_id VARCHAR) ### question:What are the title and maximum price of each film?
SELECT T2.title, MAX(T1.price) FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id
Show cinema name, film title, date, and price for each record in schedule.
CREATE TABLE schedule (date VARCHAR, price VARCHAR, film_id VARCHAR, cinema_id VARCHAR); CREATE TABLE cinema (name VARCHAR, cinema_id VARCHAR); CREATE TABLE film (title VARCHAR, film_id VARCHAR)
SELECT T3.name, T2.title, T1.date, T1.price FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id JOIN cinema AS T3 ON T1.cinema_id = T3.cinema_id
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE schedule (date VARCHAR, price VARCHAR, film_id VARCHAR, cinema_id VARCHAR); CREATE TABLE cinema (name VARCHAR, cinema_id VARCHAR); CREATE TABLE film (title VARCHAR, film_id VARCHAR) ### question:Show cinema name, film title, date, and price for each record in schedule.
SELECT T3.name, T2.title, T1.date, T1.price FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id JOIN cinema AS T3 ON T1.cinema_id = T3.cinema_id
What are the title and director of the films without any schedule?
CREATE TABLE schedule (title VARCHAR, directed_by VARCHAR, film_id VARCHAR); CREATE TABLE film (title VARCHAR, directed_by VARCHAR, film_id VARCHAR)
SELECT title, directed_by FROM film WHERE NOT film_id IN (SELECT film_id FROM schedule)
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE schedule (title VARCHAR, directed_by VARCHAR, film_id VARCHAR); CREATE TABLE film (title VARCHAR, directed_by VARCHAR, film_id VARCHAR) ### question:What are the title and director of the films without any schedule?
SELECT title, directed_by FROM film WHERE NOT film_id IN (SELECT film_id FROM schedule)
Show director with the largest number of show times in total.
CREATE TABLE schedule (film_id VARCHAR, show_times_per_day INTEGER); CREATE TABLE film (directed_by VARCHAR, film_id VARCHAR)
SELECT T2.directed_by FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.directed_by ORDER BY SUM(T1.show_times_per_day) DESC LIMIT 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE schedule (film_id VARCHAR, show_times_per_day INTEGER); CREATE TABLE film (directed_by VARCHAR, film_id VARCHAR) ### question:Show director with the largest number of show times in total.
SELECT T2.directed_by FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.directed_by ORDER BY SUM(T1.show_times_per_day) DESC LIMIT 1
Find the locations that have more than one movie theater with capacity above 300.
CREATE TABLE cinema (LOCATION VARCHAR, capacity INTEGER)
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING COUNT(*) > 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE cinema (LOCATION VARCHAR, capacity INTEGER) ### question:Find the locations that have more than one movie theater with capacity above 300.
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING COUNT(*) > 1
How many films have the word 'Dummy' in their titles?
CREATE TABLE film (title VARCHAR)
SELECT COUNT(*) FROM film WHERE title LIKE "%Dummy%"
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE film (title VARCHAR) ### question:How many films have the word 'Dummy' in their titles?
SELECT COUNT(*) FROM film WHERE title LIKE "%Dummy%"
Are the customers holding coupons with amount 500 bad or good?
CREATE TABLE discount_coupons (coupon_id VARCHAR, coupon_amount VARCHAR); CREATE TABLE customers (good_or_bad_customer VARCHAR, coupon_id VARCHAR)
SELECT T1.good_or_bad_customer FROM customers AS T1 JOIN discount_coupons AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.coupon_amount = 500
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE discount_coupons (coupon_id VARCHAR, coupon_amount VARCHAR); CREATE TABLE customers (good_or_bad_customer VARCHAR, coupon_id VARCHAR) ### question:Are the customers holding coupons with amount 500 bad or good?
SELECT T1.good_or_bad_customer FROM customers AS T1 JOIN discount_coupons AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.coupon_amount = 500
How many bookings did each customer make? List the customer id, first name, and the count.
CREATE TABLE bookings (customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, first_name VARCHAR)
SELECT T1.customer_id, T1.first_name, COUNT(*) FROM Customers AS T1 JOIN bookings AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE bookings (customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, first_name VARCHAR) ### question:How many bookings did each customer make? List the customer id, first name, and the count.
SELECT T1.customer_id, T1.first_name, COUNT(*) FROM Customers AS T1 JOIN bookings AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id
What is the maximum total amount paid by a customer? List the customer id and amount.
CREATE TABLE Payments (customer_id VARCHAR, amount_paid INTEGER)
SELECT customer_id, SUM(amount_paid) FROM Payments GROUP BY customer_id ORDER BY SUM(amount_paid) DESC LIMIT 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE Payments (customer_id VARCHAR, amount_paid INTEGER) ### question:What is the maximum total amount paid by a customer? List the customer id and amount.
SELECT customer_id, SUM(amount_paid) FROM Payments GROUP BY customer_id ORDER BY SUM(amount_paid) DESC LIMIT 1
What are the id and the amount of refund of the booking that incurred the most times of payments?
CREATE TABLE Payments (booking_id VARCHAR); CREATE TABLE Bookings (booking_id VARCHAR, amount_of_refund VARCHAR)
SELECT T1.booking_id, T1.amount_of_refund FROM Bookings AS T1 JOIN Payments AS T2 ON T1.booking_id = T2.booking_id GROUP BY T1.booking_id ORDER BY COUNT(*) DESC LIMIT 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE Payments (booking_id VARCHAR); CREATE TABLE Bookings (booking_id VARCHAR, amount_of_refund VARCHAR) ### question:What are the id and the amount of refund of the booking that incurred the most times of payments?
SELECT T1.booking_id, T1.amount_of_refund FROM Bookings AS T1 JOIN Payments AS T2 ON T1.booking_id = T2.booking_id GROUP BY T1.booking_id ORDER BY COUNT(*) DESC LIMIT 1
What is the id of the product that is booked for 3 times?
CREATE TABLE products_booked (product_id VARCHAR)
SELECT product_id FROM products_booked GROUP BY product_id HAVING COUNT(*) = 3
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE products_booked (product_id VARCHAR) ### question:What is the id of the product that is booked for 3 times?
SELECT product_id FROM products_booked GROUP BY product_id HAVING COUNT(*) = 3
What is the product description of the product booked with an amount of 102.76?
CREATE TABLE products_for_hire (product_description VARCHAR, product_id VARCHAR); CREATE TABLE products_booked (product_id VARCHAR, booked_amount VARCHAR)
SELECT T2.product_description FROM products_booked AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.booked_amount = 102.76
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE products_for_hire (product_description VARCHAR, product_id VARCHAR); CREATE TABLE products_booked (product_id VARCHAR, booked_amount VARCHAR) ### question:What is the product description of the product booked with an amount of 102.76?
SELECT T2.product_description FROM products_booked AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.booked_amount = 102.76
What are the start date and end date of the booking that has booked the product named 'Book collection A'?
CREATE TABLE bookings (booking_start_date VARCHAR, booking_end_date VARCHAR, booking_id VARCHAR); CREATE TABLE products_booked (product_id VARCHAR, booking_id VARCHAR); CREATE TABLE Products_for_hire (product_id VARCHAR, product_name VARCHAR)
SELECT T3.booking_start_date, T3.booking_end_date FROM Products_for_hire AS T1 JOIN products_booked AS T2 ON T1.product_id = T2.product_id JOIN bookings AS T3 ON T2.booking_id = T3.booking_id WHERE T1.product_name = 'Book collection A'
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE bookings (booking_start_date VARCHAR, booking_end_date VARCHAR, booking_id VARCHAR); CREATE TABLE products_booked (product_id VARCHAR, booking_id VARCHAR); CREATE TABLE Products_for_hire (product_id VARCHAR, product_name VARCHAR) ### question:What are the start date and end date of the booking that has booked the product named 'Book collection A'?
SELECT T3.booking_start_date, T3.booking_end_date FROM Products_for_hire AS T1 JOIN products_booked AS T2 ON T1.product_id = T2.product_id JOIN bookings AS T3 ON T2.booking_id = T3.booking_id WHERE T1.product_name = 'Book collection A'
What are the names of products whose availability equals to 1?
CREATE TABLE view_product_availability (product_id VARCHAR, available_yn VARCHAR); CREATE TABLE products_for_hire (product_name VARCHAR, product_id VARCHAR)
SELECT T2.product_name FROM view_product_availability AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.available_yn = 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE view_product_availability (product_id VARCHAR, available_yn VARCHAR); CREATE TABLE products_for_hire (product_name VARCHAR, product_id VARCHAR) ### question:What are the names of products whose availability equals to 1?
SELECT T2.product_name FROM view_product_availability AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.available_yn = 1
How many different product types are there?
CREATE TABLE products_for_hire (product_type_code VARCHAR)
SELECT COUNT(DISTINCT product_type_code) FROM products_for_hire
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE products_for_hire (product_type_code VARCHAR) ### question:How many different product types are there?
SELECT COUNT(DISTINCT product_type_code) FROM products_for_hire
What are the first name, last name, and gender of all the good customers? Order by their last name.
CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, gender_mf VARCHAR, good_or_bad_customer VARCHAR)
SELECT first_name, last_name, gender_mf FROM customers WHERE good_or_bad_customer = 'good' ORDER BY last_name
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, gender_mf VARCHAR, good_or_bad_customer VARCHAR) ### question:What are the first name, last name, and gender of all the good customers? Order by their last name.
SELECT first_name, last_name, gender_mf FROM customers WHERE good_or_bad_customer = 'good' ORDER BY last_name
What is the average amount due for all the payments?
CREATE TABLE payments (amount_due INTEGER)
SELECT AVG(amount_due) FROM payments
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE payments (amount_due INTEGER) ### question:What is the average amount due for all the payments?
SELECT AVG(amount_due) FROM payments
What are the maximum, minimum, and average booked count for the products booked?
CREATE TABLE products_booked (booked_count INTEGER)
SELECT MAX(booked_count), MIN(booked_count), AVG(booked_count) FROM products_booked
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE products_booked (booked_count INTEGER) ### question:What are the maximum, minimum, and average booked count for the products booked?
SELECT MAX(booked_count), MIN(booked_count), AVG(booked_count) FROM products_booked
What are all the distinct payment types?
CREATE TABLE payments (payment_type_code VARCHAR)
SELECT DISTINCT payment_type_code FROM payments
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE payments (payment_type_code VARCHAR) ### question:What are all the distinct payment types?
SELECT DISTINCT payment_type_code FROM payments
What are the daily hire costs for the products with substring 'Book' in its name?
CREATE TABLE Products_for_hire (daily_hire_cost VARCHAR, product_name VARCHAR)
SELECT daily_hire_cost FROM Products_for_hire WHERE product_name LIKE '%Book%'
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE Products_for_hire (daily_hire_cost VARCHAR, product_name VARCHAR) ### question:What are the daily hire costs for the products with substring 'Book' in its name?
SELECT daily_hire_cost FROM Products_for_hire WHERE product_name LIKE '%Book%'
How many products are never booked with amount higher than 200?
CREATE TABLE products_booked (product_id VARCHAR, booked_amount INTEGER); CREATE TABLE Products_for_hire (product_id VARCHAR, booked_amount INTEGER)
SELECT COUNT(*) FROM Products_for_hire WHERE NOT product_id IN (SELECT product_id FROM products_booked WHERE booked_amount > 200)
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE products_booked (product_id VARCHAR, booked_amount INTEGER); CREATE TABLE Products_for_hire (product_id VARCHAR, booked_amount INTEGER) ### question:How many products are never booked with amount higher than 200?
SELECT COUNT(*) FROM Products_for_hire WHERE NOT product_id IN (SELECT product_id FROM products_booked WHERE booked_amount > 200)
What are the coupon amount of the coupons owned by both good and bad customers?
CREATE TABLE Discount_Coupons (coupon_amount VARCHAR, coupon_id VARCHAR); CREATE TABLE customers (coupon_id VARCHAR, good_or_bad_customer VARCHAR)
SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'good' INTERSECT SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'bad'
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE Discount_Coupons (coupon_amount VARCHAR, coupon_id VARCHAR); CREATE TABLE customers (coupon_id VARCHAR, good_or_bad_customer VARCHAR) ### question:What are the coupon amount of the coupons owned by both good and bad customers?
SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'good' INTERSECT SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'bad'
What are the payment date of the payment with amount paid higher than 300 or with payment type is 'Check'
CREATE TABLE payments (payment_date VARCHAR, amount_paid VARCHAR, payment_type_code VARCHAR)
SELECT payment_date FROM payments WHERE amount_paid > 300 OR payment_type_code = 'Check'
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE payments (payment_date VARCHAR, amount_paid VARCHAR, payment_type_code VARCHAR) ### question:What are the payment date of the payment with amount paid higher than 300 or with payment type is 'Check'
SELECT payment_date FROM payments WHERE amount_paid > 300 OR payment_type_code = 'Check'
What are the names and descriptions of the products that are of 'Cutlery' type and have daily hire cost lower than 20?
CREATE TABLE products_for_hire (product_name VARCHAR, product_description VARCHAR, product_type_code VARCHAR, daily_hire_cost VARCHAR)
SELECT product_name, product_description FROM products_for_hire WHERE product_type_code = 'Cutlery' AND daily_hire_cost < 20
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE products_for_hire (product_name VARCHAR, product_description VARCHAR, product_type_code VARCHAR, daily_hire_cost VARCHAR) ### question:What are the names and descriptions of the products that are of 'Cutlery' type and have daily hire cost lower than 20?
SELECT product_name, product_description FROM products_for_hire WHERE product_type_code = 'Cutlery' AND daily_hire_cost < 20
How many phones are there?
CREATE TABLE phone (Id VARCHAR)
SELECT COUNT(*) FROM phone
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone (Id VARCHAR) ### question:How many phones are there?
SELECT COUNT(*) FROM phone
List the names of phones in ascending order of price.
CREATE TABLE phone (Name VARCHAR, Price VARCHAR)
SELECT Name FROM phone ORDER BY Price
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone (Name VARCHAR, Price VARCHAR) ### question:List the names of phones in ascending order of price.
SELECT Name FROM phone ORDER BY Price
What are the memories and carriers of phones?
CREATE TABLE phone (Memory_in_G VARCHAR, Carrier VARCHAR)
SELECT Memory_in_G, Carrier FROM phone
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone (Memory_in_G VARCHAR, Carrier VARCHAR) ### question:What are the memories and carriers of phones?
SELECT Memory_in_G, Carrier FROM phone
List the distinct carriers of phones with memories bigger than 32.
CREATE TABLE phone (Carrier VARCHAR, Memory_in_G INTEGER)
SELECT DISTINCT Carrier FROM phone WHERE Memory_in_G > 32
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone (Carrier VARCHAR, Memory_in_G INTEGER) ### question:List the distinct carriers of phones with memories bigger than 32.
SELECT DISTINCT Carrier FROM phone WHERE Memory_in_G > 32
Show the names of phones with carrier either "Sprint" or "TMobile".
CREATE TABLE phone (Name VARCHAR, Carrier VARCHAR)
SELECT Name FROM phone WHERE Carrier = "Sprint" OR Carrier = "TMobile"
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone (Name VARCHAR, Carrier VARCHAR) ### question:Show the names of phones with carrier either "Sprint" or "TMobile".
SELECT Name FROM phone WHERE Carrier = "Sprint" OR Carrier = "TMobile"
What is the carrier of the most expensive phone?
CREATE TABLE phone (Carrier VARCHAR, Price VARCHAR)
SELECT Carrier FROM phone ORDER BY Price DESC LIMIT 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone (Carrier VARCHAR, Price VARCHAR) ### question:What is the carrier of the most expensive phone?
SELECT Carrier FROM phone ORDER BY Price DESC LIMIT 1
Show different carriers of phones together with the number of phones with each carrier.
CREATE TABLE phone (Carrier VARCHAR)
SELECT Carrier, COUNT(*) FROM phone GROUP BY Carrier
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone (Carrier VARCHAR) ### question:Show different carriers of phones together with the number of phones with each carrier.
SELECT Carrier, COUNT(*) FROM phone GROUP BY Carrier
Show the most frequently used carrier of the phones.
CREATE TABLE phone (Carrier VARCHAR)
SELECT Carrier FROM phone GROUP BY Carrier ORDER BY COUNT(*) DESC LIMIT 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone (Carrier VARCHAR) ### question:Show the most frequently used carrier of the phones.
SELECT Carrier FROM phone GROUP BY Carrier ORDER BY COUNT(*) DESC LIMIT 1
Show the carriers that have both phones with memory smaller than 32 and phones with memory bigger than 64.
CREATE TABLE phone (Carrier VARCHAR, Memory_in_G INTEGER)
SELECT Carrier FROM phone WHERE Memory_in_G < 32 INTERSECT SELECT Carrier FROM phone WHERE Memory_in_G > 64
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone (Carrier VARCHAR, Memory_in_G INTEGER) ### question:Show the carriers that have both phones with memory smaller than 32 and phones with memory bigger than 64.
SELECT Carrier FROM phone WHERE Memory_in_G < 32 INTERSECT SELECT Carrier FROM phone WHERE Memory_in_G > 64
Show the names of phones and the districts of markets they are on.
CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE market (District VARCHAR, Market_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)
SELECT T3.Name, T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE market (District VARCHAR, Market_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR) ### question:Show the names of phones and the districts of markets they are on.
SELECT T3.Name, T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID
Show the names of phones and the districts of markets they are on, in ascending order of the ranking of the market.
CREATE TABLE market (District VARCHAR, Market_ID VARCHAR, Ranking VARCHAR); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)
SELECT T3.Name, T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID ORDER BY T2.Ranking
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE market (District VARCHAR, Market_ID VARCHAR, Ranking VARCHAR); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR) ### question:Show the names of phones and the districts of markets they are on, in ascending order of the ranking of the market.
SELECT T3.Name, T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID ORDER BY T2.Ranking
Show the names of phones that are on market with number of shops greater than 50.
CREATE TABLE market (Market_ID VARCHAR, Num_of_shops INTEGER); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)
SELECT T3.Name FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID WHERE T2.Num_of_shops > 50
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE market (Market_ID VARCHAR, Num_of_shops INTEGER); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR) ### question:Show the names of phones that are on market with number of shops greater than 50.
SELECT T3.Name FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID WHERE T2.Num_of_shops > 50
For each phone, show its names and total number of stocks.
CREATE TABLE phone_market (Num_of_stock INTEGER, Phone_ID VARCHAR); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR)
SELECT T2.Name, SUM(T1.Num_of_stock) FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone_market (Num_of_stock INTEGER, Phone_ID VARCHAR); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR) ### question:For each phone, show its names and total number of stocks.
SELECT T2.Name, SUM(T1.Num_of_stock) FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name
Show the names of phones that have total number of stocks bigger than 2000, in descending order of the total number of stocks.
CREATE TABLE phone_market (Phone_ID VARCHAR, Num_of_stock INTEGER); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR)
SELECT T2.Name FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name HAVING SUM(T1.Num_of_stock) >= 2000 ORDER BY SUM(T1.Num_of_stock) DESC
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone_market (Phone_ID VARCHAR, Num_of_stock INTEGER); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR) ### question:Show the names of phones that have total number of stocks bigger than 2000, in descending order of the total number of stocks.
SELECT T2.Name FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name HAVING SUM(T1.Num_of_stock) >= 2000 ORDER BY SUM(T1.Num_of_stock) DESC
List the names of phones that are not on any market.
CREATE TABLE phone (Name VARCHAR, Phone_id VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Name VARCHAR, Phone_id VARCHAR, Phone_ID VARCHAR)
SELECT Name FROM phone WHERE NOT Phone_id IN (SELECT Phone_ID FROM phone_market)
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE phone (Name VARCHAR, Phone_id VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Name VARCHAR, Phone_id VARCHAR, Phone_ID VARCHAR) ### question:List the names of phones that are not on any market.
SELECT Name FROM phone WHERE NOT Phone_id IN (SELECT Phone_ID FROM phone_market)
How many gas companies are there?
CREATE TABLE company (Id VARCHAR)
SELECT COUNT(*) FROM company
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE company (Id VARCHAR) ### question:How many gas companies are there?
SELECT COUNT(*) FROM company
List the company name and rank for all companies in the decreasing order of their sales.
CREATE TABLE company (company VARCHAR, rank VARCHAR, Sales_billion VARCHAR)
SELECT company, rank FROM company ORDER BY Sales_billion DESC
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE company (company VARCHAR, rank VARCHAR, Sales_billion VARCHAR) ### question:List the company name and rank for all companies in the decreasing order of their sales.
SELECT company, rank FROM company ORDER BY Sales_billion DESC
Show the company name and the main industry for all companies whose headquarters are not from USA.
CREATE TABLE company (company VARCHAR, main_industry VARCHAR, headquarters VARCHAR)
SELECT company, main_industry FROM company WHERE headquarters <> 'USA'
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE company (company VARCHAR, main_industry VARCHAR, headquarters VARCHAR) ### question:Show the company name and the main industry for all companies whose headquarters are not from USA.
SELECT company, main_industry FROM company WHERE headquarters <> 'USA'
Show all company names and headquarters in the descending order of market value.
CREATE TABLE company (company VARCHAR, headquarters VARCHAR, market_value VARCHAR)
SELECT company, headquarters FROM company ORDER BY market_value DESC
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE company (company VARCHAR, headquarters VARCHAR, market_value VARCHAR) ### question:Show all company names and headquarters in the descending order of market value.
SELECT company, headquarters FROM company ORDER BY market_value DESC
Show minimum, maximum, and average market value for all companies.
CREATE TABLE company (market_value INTEGER)
SELECT MIN(market_value), MAX(market_value), AVG(market_value) FROM company
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE company (market_value INTEGER) ### question:Show minimum, maximum, and average market value for all companies.
SELECT MIN(market_value), MAX(market_value), AVG(market_value) FROM company
Show all main industry for all companies.
CREATE TABLE company (main_industry VARCHAR)
SELECT DISTINCT main_industry FROM company
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE company (main_industry VARCHAR) ### question:Show all main industry for all companies.
SELECT DISTINCT main_industry FROM company
List all headquarters and the number of companies in each headquarter.
CREATE TABLE company (headquarters VARCHAR)
SELECT headquarters, COUNT(*) FROM company GROUP BY headquarters
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE company (headquarters VARCHAR) ### question:List all headquarters and the number of companies in each headquarter.
SELECT headquarters, COUNT(*) FROM company GROUP BY headquarters
Show all main industry and total market value in each industry.
CREATE TABLE company (main_industry VARCHAR, market_value INTEGER)
SELECT main_industry, SUM(market_value) FROM company GROUP BY main_industry
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE company (main_industry VARCHAR, market_value INTEGER) ### question:Show all main industry and total market value in each industry.
SELECT main_industry, SUM(market_value) FROM company GROUP BY main_industry
List the main industry with highest total market value and its number of companies.
CREATE TABLE company (main_industry VARCHAR, market_value INTEGER)
SELECT main_industry, COUNT(*) FROM company GROUP BY main_industry ORDER BY SUM(market_value) DESC LIMIT 1
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE company (main_industry VARCHAR, market_value INTEGER) ### question:List the main industry with highest total market value and its number of companies.
SELECT main_industry, COUNT(*) FROM company GROUP BY main_industry ORDER BY SUM(market_value) DESC LIMIT 1
Show headquarters with at least two companies in the banking industry.
CREATE TABLE company (headquarters VARCHAR, main_industry VARCHAR)
SELECT headquarters FROM company WHERE main_industry = 'Banking' GROUP BY headquarters HAVING COUNT(*) >= 2
Translate the question into SQL query by using the schema. ### schema:CREATE TABLE company (headquarters VARCHAR, main_industry VARCHAR) ### question:Show headquarters with at least two companies in the banking industry.
SELECT headquarters FROM company WHERE main_industry = 'Banking' GROUP BY headquarters HAVING COUNT(*) >= 2