query_id
int64
0
7k
database_id
stringclasses
140 values
table_id
sequencelengths
1
5
query
stringlengths
16
224
answer
stringlengths
18
577
difficulty
stringclasses
4 values
1,900
school_finance
[ "budget" ]
How many budgets are above 3000 in year 2001 or before?
SELECT count(*) FROM budget WHERE budgeted > 3000 AND YEAR <= 2001
medium
1,901
school_finance
[ "budget" ]
Count the number of budgets in year 2001 or before whose budgeted amount is greater than 3000
SELECT count(*) FROM budget WHERE budgeted > 3000 AND YEAR <= 2001
medium
1,902
school_finance
[ "school", "budget" ]
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
medium
1,903
school_finance
[ "endowment" ]
Show all donor names.
SELECT DISTINCT donator_name FROM endowment
easy
1,904
school_finance
[ "budget" ]
How many budget record has a budget amount smaller than the invested amount?
SELECT count(*) FROM budget WHERE budgeted < invested
easy
1,905
school_finance
[ "school", "budget" ]
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'
medium
1,906
school_finance
[ "school", "budget", "endowment" ]
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
extra
1,907
school_finance
[ "endowment", "school" ]
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
hard
1,908
school_finance
[ "endowment" ]
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)
easy
1,909
school_finance
[ "school", "budget" ]
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
extra
1,910
protein_institute
[ "building" ]
How many buildings are there?
SELECT count(*) FROM building
easy
1,911
protein_institute
[ "building" ]
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
medium
1,912
protein_institute
[ "building" ]
What is the name of the tallest building?
SELECT name FROM building ORDER BY height_feet DESC LIMIT 1
medium
1,913
protein_institute
[ "building" ]
What are the average, maximum, and minimum number of floors for all buildings?
SELECT avg(floors) , max(floors) , min(floors) FROM building
medium
1,914
protein_institute
[ "building" ]
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)
extra
1,915
protein_institute
[ "building" ]
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
medium
1,916
protein_institute
[ "institution" ]
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'
medium
1,917
protein_institute
[ "institution" ]
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
medium
1,918
protein_institute
[ "institution" ]
Show the institution type with the largest number of institutions.
SELECT TYPE FROM institution GROUP BY TYPE ORDER BY count(*) DESC LIMIT 1
hard
1,919
protein_institute
[ "institution" ]
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
medium
1,920
protein_institute
[ "building", "institution" ]
Show the name of buildings that do not have any institution.
SELECT name FROM building WHERE building_id NOT IN (SELECT building_id FROM institution)
hard
1,921
protein_institute
[ "building", "institution" ]
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
hard
1,922
protein_institute
[ "building", "institution" ]
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
medium
1,923
protein_institute
[ "building", "institution" ]
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
hard
1,924
protein_institute
[ "institution" ]
Show all the distinct institution types.
SELECT DISTINCT TYPE FROM institution
easy
1,925
protein_institute
[ "protein", "institution" ]
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
medium
1,926
protein_institute
[ "protein", "institution" ]
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'
hard
1,927
protein_institute
[ "protein", "institution" ]
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
medium
1,928
protein_institute
[ "building", "protein", "institution" ]
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
hard
1,929
protein_institute
[ "protein", "institution" ]
How many institutions do not have an associated protein in our record?
SELECT count(*) FROM institution WHERE institution_id NOT IN (SELECT institution_id FROM protein)
extra
1,930
cinema
[ "cinema" ]
Show all the locations where no cinema has capacity over 800.
SELECT LOCATION FROM cinema EXCEPT SELECT LOCATION FROM cinema WHERE capacity > 800
hard
1,931
cinema
[ "cinema" ]
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
hard
1,932
cinema
[ "cinema" ]
How many cinema do we have?
SELECT count(*) FROM cinema
easy
1,933
cinema
[ "cinema" ]
Count the number of cinemas.
SELECT count(*) FROM cinema
easy
1,934
cinema
[ "cinema" ]
Show name, opening year, and capacity for each cinema.
SELECT name , openning_year , capacity FROM cinema
medium
1,935
cinema
[ "cinema" ]
Show the cinema name and location for cinemas with capacity above average.
SELECT name , LOCATION FROM cinema WHERE capacity > (SELECT avg(capacity) FROM cinema)
extra
1,936
cinema
[ "cinema" ]
What are all the locations with a cinema?
SELECT DISTINCT LOCATION FROM cinema
easy
1,937
cinema
[ "cinema" ]
Find the distinct locations that has a cinema.
SELECT DISTINCT LOCATION FROM cinema
easy
1,938
cinema
[ "cinema" ]
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
medium
1,939
cinema
[ "cinema" ]
What are the name and location of the cinema with the largest capacity?
SELECT name , LOCATION FROM cinema ORDER BY capacity DESC LIMIT 1
medium
1,940
cinema
[ "cinema" ]
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
medium
1,941
cinema
[ "cinema" ]
Show each location and the number of cinemas there.
SELECT LOCATION , count(*) FROM cinema GROUP BY LOCATION
medium
1,942
cinema
[ "cinema" ]
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
extra
1,943
cinema
[ "cinema" ]
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
medium
1,944
cinema
[ "cinema" ]
Which locations have 2 or more cinemas with capacity over 300?
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) >= 2
medium
1,945
cinema
[ "film" ]
Show the title and director for all films.
SELECT title , directed_by FROM film
medium
1,946
cinema
[ "film" ]
What are the title and director of each film?
SELECT title , directed_by FROM film
medium
1,947
cinema
[ "film" ]
Show all directors.
SELECT DISTINCT directed_by FROM film
easy
1,948
cinema
[ "film" ]
Who are all the directors?
SELECT DISTINCT directed_by FROM film
easy
1,949
cinema
[ "film" ]
List all directors along with the number of films directed by each director.
SELECT directed_by , count(*) FROM film GROUP BY directed_by
medium
1,950
cinema
[ "cinema", "schedule" ]
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
medium
1,951
cinema
[ "schedule", "film" ]
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
medium
1,952
cinema
[ "schedule", "film" ]
Give me the title and highest price for 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
medium
1,953
cinema
[ "cinema", "schedule", "film" ]
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
medium
1,954
cinema
[ "schedule", "film" ]
What are the title and director of the films without any schedule?
SELECT title , directed_by FROM film WHERE film_id NOT IN (SELECT film_id FROM schedule)
extra
1,955
cinema
[ "schedule", "film" ]
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
extra
1,956
cinema
[ "cinema" ]
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
medium
1,957
cinema
[ "cinema" ]
In which locations are there more than one movie theater with capacity above 300?
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) > 1
medium
1,958
cinema
[ "film" ]
How many films have the word 'Dummy' in their titles?
SELECT count(*) FROM film WHERE title LIKE "%Dummy%"
medium
1,959
cinema
[ "film" ]
Count the number of films whose title contains the word 'Dummy'.
SELECT count(*) FROM film WHERE title LIKE "%Dummy%"
medium
1,960
products_for_hire
[ "discount_coupons", "customers" ]
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
medium
1,961
products_for_hire
[ "bookings", "Customers" ]
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
medium
1,962
products_for_hire
[ "Payments" ]
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
hard
1,963
products_for_hire
[ "Payments", "Bookings" ]
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
extra
1,964
products_for_hire
[ "products_booked" ]
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
easy
1,965
products_for_hire
[ "products_for_hire", "products_booked" ]
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
medium
1,966
products_for_hire
[ "bookings", "Products_for_hire", "products_booked" ]
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'
hard
1,967
products_for_hire
[ "products_for_hire", "view_product_availability" ]
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
medium
1,968
products_for_hire
[ "products_for_hire" ]
How many different product types are there?
SELECT count(DISTINCT product_type_code) FROM products_for_hire
easy
1,969
products_for_hire
[ "customers" ]
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
medium
1,970
products_for_hire
[ "payments" ]
What is the average amount due for all the payments?
SELECT avg(amount_due) FROM payments
easy
1,971
products_for_hire
[ "products_booked" ]
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
medium
1,972
products_for_hire
[ "payments" ]
What are all the distinct payment types?
SELECT DISTINCT payment_type_code FROM payments
easy
1,973
products_for_hire
[ "Products_for_hire" ]
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%'
medium
1,974
products_for_hire
[ "Products_for_hire", "products_booked" ]
How many products are never booked with amount higher than 200?
SELECT count(*) FROM Products_for_hire WHERE product_id NOT IN ( SELECT product_id FROM products_booked WHERE booked_amount > 200 )
extra
1,975
products_for_hire
[ "Discount_Coupons", "customers" ]
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'
extra
1,976
products_for_hire
[ "payments" ]
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'
medium
1,977
products_for_hire
[ "products_for_hire" ]
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
medium
1,978
phone_market
[ "phone" ]
How many phones are there?
SELECT count(*) FROM phone
easy
1,979
phone_market
[ "phone" ]
List the names of phones in ascending order of price.
SELECT Name FROM phone ORDER BY Price ASC
easy
1,980
phone_market
[ "phone" ]
What are the memories and carriers of phones?
SELECT Memory_in_G , Carrier FROM phone
medium
1,981
phone_market
[ "phone" ]
List the distinct carriers of phones with memories bigger than 32.
SELECT DISTINCT Carrier FROM phone WHERE Memory_in_G > 32
easy
1,982
phone_market
[ "phone" ]
Show the names of phones with carrier either "Sprint" or "TMobile".
SELECT Name FROM phone WHERE Carrier = "Sprint" OR Carrier = "TMobile"
medium
1,983
phone_market
[ "phone" ]
What is the carrier of the most expensive phone?
SELECT Carrier FROM phone ORDER BY Price DESC LIMIT 1
medium
1,984
phone_market
[ "phone" ]
Show different carriers of phones together with the number of phones with each carrier.
SELECT Carrier , COUNT(*) FROM phone GROUP BY Carrier
medium
1,985
phone_market
[ "phone" ]
Show the most frequently used carrier of the phones.
SELECT Carrier FROM phone GROUP BY Carrier ORDER BY COUNT(*) DESC LIMIT 1
hard
1,986
phone_market
[ "phone" ]
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
hard
1,987
phone_market
[ "phone_market", "market", "phone" ]
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
medium
1,988
phone_market
[ "phone_market", "market", "phone" ]
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
hard
1,989
phone_market
[ "phone_market", "market", "phone" ]
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
hard
1,990
phone_market
[ "phone_market", "phone" ]
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
medium
1,991
phone_market
[ "phone_market", "phone" ]
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
hard
1,992
phone_market
[ "phone_market", "phone" ]
List the names of phones that are not on any market.
SELECT Name FROM phone WHERE Phone_id NOT IN (SELECT Phone_ID FROM phone_market)
hard
1,993
gas_company
[ "company" ]
How many gas companies are there?
SELECT count(*) FROM company
easy
1,994
gas_company
[ "company" ]
What is the total number of companies?
SELECT count(*) FROM company
easy
1,995
gas_company
[ "company" ]
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
medium
1,996
gas_company
[ "company" ]
What is the name and rank of every company ordered by descending number of sales?
SELECT company , rank FROM company ORDER BY Sales_billion DESC
medium
1,997
gas_company
[ "company" ]
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'
medium
1,998
gas_company
[ "company" ]
What are the companies and main industries of all companies that are not headquartered in the United States?
SELECT company , main_industry FROM company WHERE headquarters != 'USA'
medium
1,999
gas_company
[ "company" ]
Show all company names and headquarters in the descending order of market value.
SELECT company , headquarters FROM company ORDER BY market_value DESC
medium