question_id
int64
1
75.7k
db_id
stringclasses
33 values
db_name
stringclasses
4 values
question
stringlengths
19
259
partition
stringclasses
4 values
difficulty
stringclasses
3 values
SQL
stringlengths
25
862
1,001
restaurant_bills
spider
Show distinct managers of branches.
test
easy
SELECT DISTINCT manager FROM branch
1,002
restaurant_bills
spider
Who are the distinct managers of branches?
test
easy
SELECT DISTINCT manager FROM branch
1,003
restaurant_bills
spider
List the names of customers that do not have any order.
test
medium
SELECT name FROM customer WHERE NOT customer_id IN (SELECT customer_id FROM customer_order)
1,004
restaurant_bills
spider
Which customers do not have any order? Give me the customer names.
test
medium
SELECT name FROM customer WHERE NOT customer_id IN (SELECT customer_id FROM customer_order)
1,005
real_estate_rentals
spider
Which countries and cities are included in addresses?
test
easy
SELECT country, town_city FROM addresses
1,006
real_estate_rentals
spider
What are the countries and cities for each address?
test
easy
SELECT country, town_city FROM addresses
1,007
real_estate_rentals
spider
In which states are each of the the properties located?
test
hard
SELECT DISTINCT t1.county_state_province FROM addresses AS t1 JOIN properties AS t2 ON t1.address_id = t2.property_address_id
1,008
real_estate_rentals
spider
Give the states or provinces corresponding to each property.
test
hard
SELECT DISTINCT t1.county_state_province FROM addresses AS t1 JOIN properties AS t2 ON t1.address_id = t2.property_address_id
1,009
real_estate_rentals
spider
How is the feature rooftop described?
test
easy
SELECT feature_description FROM features WHERE feature_name = 'rooftop'
1,010
real_estate_rentals
spider
Return the description of the feature 'rooftop'.
test
easy
SELECT feature_description FROM features WHERE feature_name = 'rooftop'
1,011
real_estate_rentals
spider
What are the feature name and description of the most commonly seen feature across properties?
test
hard
SELECT t1.feature_name, t1.feature_description FROM features AS t1 JOIN property_features AS t2 ON t1.feature_id = t2.feature_id GROUP BY t1.feature_name ORDER BY COUNT(*) DESC LIMIT 1
1,012
real_estate_rentals
spider
Give the feature name and description for the most common feature across all properties.
test
hard
SELECT t1.feature_name, t1.feature_description FROM features AS t1 JOIN property_features AS t2 ON t1.feature_id = t2.feature_id GROUP BY t1.feature_name ORDER BY COUNT(*) DESC LIMIT 1
1,013
real_estate_rentals
spider
What is the minimum number of rooms in a property?
test
easy
SELECT MIN(room_count) FROM properties
1,014
real_estate_rentals
spider
What is the lowest room count across all the properties?
test
easy
SELECT MIN(room_count) FROM properties
1,015
real_estate_rentals
spider
How many properties have 1 parking lot or 1 garage?
test
medium
SELECT COUNT(*) FROM properties WHERE parking_lots = 1 OR garage_yn = 1
1,016
real_estate_rentals
spider
Count the number of properties that have 1 parking lot or 1 garage.
test
medium
SELECT COUNT(*) FROM properties WHERE parking_lots = 1 OR garage_yn = 1
1,017
real_estate_rentals
spider
For users whose description contain the string 'Mother', which age categories are they in?
test
hard
SELECT t2.age_category_code FROM ref_user_categories AS t1 JOIN users AS t2 ON t1.user_category_code = t2.user_category_code WHERE t1.user_category_description LIKE '%mother'
1,018
real_estate_rentals
spider
What are the age categories for users whose description contains the string Mother?
test
hard
SELECT t2.age_category_code FROM ref_user_categories AS t1 JOIN users AS t2 ON t1.user_category_code = t2.user_category_code WHERE t1.user_category_description LIKE '%mother'
1,019
real_estate_rentals
spider
What is the first name of the user who owns the greatest number of properties?
test
hard
SELECT t1.first_name FROM users AS t1 JOIN properties AS t2 ON t2.owner_user_id = t1.user_id GROUP BY t1.user_id ORDER BY COUNT(*) DESC LIMIT 1
1,020
real_estate_rentals
spider
Return the first name of the user who owns the most properties.
test
hard
SELECT t1.first_name FROM users AS t1 JOIN properties AS t2 ON t2.owner_user_id = t1.user_id GROUP BY t1.user_id ORDER BY COUNT(*) DESC LIMIT 1
1,021
real_estate_rentals
spider
List the average room count of the properties with gardens.
test
hard
SELECT AVG(t3.room_count) FROM property_features AS t1 JOIN features AS t2 ON t1.feature_id = t2.feature_id JOIN properties AS t3 ON t1.property_id = t3.property_id WHERE t2.feature_name = 'garden'
1,022
real_estate_rentals
spider
On average, how many rooms do properties with garden features have?
test
hard
SELECT AVG(t3.room_count) FROM property_features AS t1 JOIN features AS t2 ON t1.feature_id = t2.feature_id JOIN properties AS t3 ON t1.property_id = t3.property_id WHERE t2.feature_name = 'garden'
1,023
real_estate_rentals
spider
In which cities are there any properties equipped with a swimming pool?
test
hard
SELECT t2.town_city FROM properties AS t1 JOIN addresses AS t2 ON t1.property_address_id = t2.address_id JOIN property_features AS t3 ON t1.property_id = t3.property_id JOIN features AS t4 ON t4.feature_id = t3.feature_id WHERE t4.feature_name = 'swimming pool'
1,024
real_estate_rentals
spider
Return the cities in which there exist properties that have swimming pools.
test
hard
SELECT t2.town_city FROM properties AS t1 JOIN addresses AS t2 ON t1.property_address_id = t2.address_id JOIN property_features AS t3 ON t1.property_id = t3.property_id JOIN features AS t4 ON t4.feature_id = t3.feature_id WHERE t4.feature_name = 'swimming pool'
1,025
real_estate_rentals
spider
Which property had the lowest price requested by the vendor? List the id and the price.
test
hard
SELECT property_id, vendor_requested_price FROM properties ORDER BY vendor_requested_price LIMIT 1
1,026
real_estate_rentals
spider
What is the id of the property that had the lowest requested price from the vendor, and what was that price?
test
hard
SELECT property_id, vendor_requested_price FROM properties ORDER BY vendor_requested_price LIMIT 1
1,027
real_estate_rentals
spider
On average, how many rooms does a property have?
test
easy
SELECT AVG(room_count) FROM properties
1,028
real_estate_rentals
spider
What is the average number of rooms in a property?
test
easy
SELECT AVG(room_count) FROM properties
1,029
real_estate_rentals
spider
How many kinds of room sizes are listed?
test
easy
SELECT COUNT(DISTINCT room_size) FROM rooms
1,030
real_estate_rentals
spider
Return the number of different room sizes.
test
easy
SELECT COUNT(DISTINCT room_size) FROM rooms
1,031
real_estate_rentals
spider
What are the ids of users who have searched at least twice, and what did they search?
test
hard
SELECT search_seq, user_id FROM user_searches GROUP BY user_id HAVING COUNT(*) >= 2
1,032
real_estate_rentals
spider
Return the ids of users who have performed two or more searches, as well as their search sequence.
test
hard
SELECT search_seq, user_id FROM user_searches GROUP BY user_id HAVING COUNT(*) >= 2
1,033
real_estate_rentals
spider
When was the time of the latest search by a user?
test
easy
SELECT MAX(search_datetime) FROM user_searches
1,034
real_estate_rentals
spider
What was the time of the most recent search?
test
easy
SELECT MAX(search_datetime) FROM user_searches
1,035
real_estate_rentals
spider
What are all the user searches time and content? Sort the result descending by content.
test
hard
SELECT search_datetime, search_string FROM user_searches ORDER BY search_string DESC
1,036
real_estate_rentals
spider
Return the search strings and corresonding time stamps for all user searches, sorted by search string descending.
test
hard
SELECT search_datetime, search_string FROM user_searches ORDER BY search_string DESC
1,037
real_estate_rentals
spider
What are the zip codes of properties which do not belong to users who own at most 2 properties?
test
hard
SELECT t1.zip_postcode FROM addresses AS t1 JOIN properties AS t2 ON t1.address_id = t2.property_address_id WHERE NOT t2.owner_user_id IN (SELECT owner_user_id FROM properties GROUP BY owner_user_id HAVING COUNT(*) <= 2)
1,038
real_estate_rentals
spider
Return the zip codes for properties not belonging to users who own two or fewer properties.
test
hard
SELECT t1.zip_postcode FROM addresses AS t1 JOIN properties AS t2 ON t1.address_id = t2.property_address_id WHERE NOT t2.owner_user_id IN (SELECT owner_user_id FROM properties GROUP BY owner_user_id HAVING COUNT(*) <= 2)
1,039
real_estate_rentals
spider
What are the users making only one search? List both category and user id.
test
hard
SELECT t1.user_category_code, t1.user_id FROM users AS t1 JOIN user_searches AS t2 ON t1.user_id = t2.user_id GROUP BY t1.user_id HAVING COUNT(*) = 1
1,040
real_estate_rentals
spider
What are the ids of users who have only made one search, and what are their category codes?
test
hard
SELECT t1.user_category_code, t1.user_id FROM users AS t1 JOIN user_searches AS t2 ON t1.user_id = t2.user_id GROUP BY t1.user_id HAVING COUNT(*) = 1
1,041
real_estate_rentals
spider
What is the age range category of the user who made the first search?
test
hard
SELECT t1.age_category_code FROM users AS t1 JOIN user_searches AS t2 ON t1.user_id = t2.user_id ORDER BY t2.search_datetime LIMIT 1
1,042
real_estate_rentals
spider
Return the age category for the user who made the earliest search.
test
hard
SELECT t1.age_category_code FROM users AS t1 JOIN user_searches AS t2 ON t1.user_id = t2.user_id ORDER BY t2.search_datetime LIMIT 1
1,043
real_estate_rentals
spider
Find the login names of all senior citizen users ordered by their first names.
test
medium
SELECT login_name FROM users WHERE user_category_code = 'senior citizen' ORDER BY first_name
1,044
real_estate_rentals
spider
What are the login names of all senior citizens, sorted by first name?
test
medium
SELECT login_name FROM users WHERE user_category_code = 'senior citizen' ORDER BY first_name
1,045
real_estate_rentals
spider
How many searches do buyers make in total?
test
hard
SELECT COUNT(*) FROM users AS t1 JOIN user_searches AS t2 ON t1.user_id = t2.user_id WHERE t1.is_buyer = 1
1,046
real_estate_rentals
spider
Count the number of searches made by buyers.
test
hard
SELECT COUNT(*) FROM users AS t1 JOIN user_searches AS t2 ON t1.user_id = t2.user_id WHERE t1.is_buyer = 1
1,047
real_estate_rentals
spider
When did the user with login name ratione register?
test
easy
SELECT date_registered FROM users WHERE login_name = 'ratione'
1,048
real_estate_rentals
spider
What was the registration date for the user whose login name is ratione?
test
easy
SELECT date_registered FROM users WHERE login_name = 'ratione'
1,049
real_estate_rentals
spider
List the first name, middle name and last name, and log in name of all the seller users, whose seller value is 1.
test
easy
SELECT first_name, middle_name, last_name, login_name FROM users WHERE is_seller = 1
1,050
real_estate_rentals
spider
What are the first, middle, last, and login names for all users who are sellers?
test
easy
SELECT first_name, middle_name, last_name, login_name FROM users WHERE is_seller = 1
1,051
real_estate_rentals
spider
Where do the Senior Citizens live? List building, street, and the city.
test
hard
SELECT t1.line_1_number_building, t1.line_2_number_street, t1.town_city FROM addresses AS t1 JOIN users AS t2 ON t1.address_id = t2.user_address_id WHERE t2.user_category_code = 'senior citizen'
1,052
real_estate_rentals
spider
What are the buildings, streets, and cities corresponding to the addresses of senior citizens?
test
hard
SELECT t1.line_1_number_building, t1.line_2_number_street, t1.town_city FROM addresses AS t1 JOIN users AS t2 ON t1.address_id = t2.user_address_id WHERE t2.user_category_code = 'senior citizen'
1,053
real_estate_rentals
spider
How many properties are there with at least 2 features?
test
hard
SELECT COUNT(*) FROM properties GROUP BY property_id HAVING COUNT(*) >= 2
1,054
real_estate_rentals
spider
Count the number of properties with at least two features.
test
hard
SELECT COUNT(*) FROM properties GROUP BY property_id HAVING COUNT(*) >= 2
1,055
real_estate_rentals
spider
How many photos does each property have?
test
hard
SELECT COUNT(*), property_id FROM property_photos GROUP BY property_id
1,056
real_estate_rentals
spider
Count the number of property photos each property has by id.
test
hard
SELECT COUNT(*), property_id FROM property_photos GROUP BY property_id
1,057
real_estate_rentals
spider
How many photos does each owner has of his or her properties? List user id and number of photos.
test
hard
SELECT t1.owner_user_id, COUNT(*) FROM properties AS t1 JOIN property_photos AS t2 ON t1.property_id = t2.property_id GROUP BY t1.owner_user_id
1,058
real_estate_rentals
spider
What are the user ids of property owners who have property photos, and how many do each of them have?
test
hard
SELECT t1.owner_user_id, COUNT(*) FROM properties AS t1 JOIN property_photos AS t2 ON t1.property_id = t2.property_id GROUP BY t1.owner_user_id
1,059
real_estate_rentals
spider
What is the total max price of the properties owned by single mothers or students?
test
hard
SELECT SUM(t1.price_max) FROM properties AS t1 JOIN users AS t2 ON t1.owner_user_id = t2.user_id WHERE t2.user_category_code = 'single mother' OR t2.user_category_code = 'student'
1,060
real_estate_rentals
spider
Give the total max price corresponding to any properties owned by single mothers or students.
test
hard
SELECT SUM(t1.price_max) FROM properties AS t1 JOIN users AS t2 ON t1.owner_user_id = t2.user_id WHERE t2.user_category_code = 'single mother' OR t2.user_category_code = 'student'
1,061
real_estate_rentals
spider
What are the date stamps and property names for each item of property history, ordered by date stamp?
test
hard
SELECT t1.datestamp, t2.property_name FROM user_property_history AS t1 JOIN properties AS t2 ON t1.property_id = t2.property_id ORDER BY datestamp
1,062
real_estate_rentals
spider
Return the date stamp and property name for each property history event, sorted by date stamp.
test
hard
SELECT t1.datestamp, t2.property_name FROM user_property_history AS t1 JOIN properties AS t2 ON t1.property_id = t2.property_id ORDER BY datestamp
1,063
real_estate_rentals
spider
What is the description of the most common property type? List the description and code.
test
hard
SELECT t1.property_type_description, t1.property_type_code FROM ref_property_types AS t1 JOIN properties AS t2 ON t1.property_type_code = t2.property_type_code GROUP BY t1.property_type_code ORDER BY COUNT(*) DESC LIMIT 1
1,064
real_estate_rentals
spider
What is the most common property type, and what is its description.
test
hard
SELECT t1.property_type_description, t1.property_type_code FROM ref_property_types AS t1 JOIN properties AS t2 ON t1.property_type_code = t2.property_type_code GROUP BY t1.property_type_code ORDER BY COUNT(*) DESC LIMIT 1
1,065
real_estate_rentals
spider
What is the detailed description of the age category code 'Over 60'?
test
medium
SELECT age_category_description FROM ref_age_categories WHERE age_category_code = 'over 60'
1,066
real_estate_rentals
spider
Give the category description of the age category 'Over 60'.
test
medium
SELECT age_category_description FROM ref_age_categories WHERE age_category_code = 'over 60'
1,067
real_estate_rentals
spider
What are the different room sizes, and how many of each are there?
test
hard
SELECT room_size, COUNT(*) FROM rooms GROUP BY room_size
1,068
real_estate_rentals
spider
Return the number of rooms with each different room size.
test
hard
SELECT room_size, COUNT(*) FROM rooms GROUP BY room_size
1,069
real_estate_rentals
spider
In which country does the user with first name Robbie live?
test
hard
SELECT t1.country FROM addresses AS t1 JOIN users AS t2 ON t1.address_id = t2.user_address_id WHERE t2.first_name = 'robbie'
1,070
real_estate_rentals
spider
Return the country in which the user with first name Robbie lives.
test
hard
SELECT t1.country FROM addresses AS t1 JOIN users AS t2 ON t1.address_id = t2.user_address_id WHERE t2.first_name = 'robbie'
1,071
real_estate_rentals
spider
What are the first, middle and last names of users who own the property they live in?
test
hard
SELECT first_name, middle_name, last_name FROM properties AS t1 JOIN users AS t2 ON t1.owner_user_id = t2.user_id WHERE t1.property_address_id = t2.user_address_id
1,072
real_estate_rentals
spider
Return the full names of users who live in properties that they own.
test
hard
SELECT first_name, middle_name, last_name FROM properties AS t1 JOIN users AS t2 ON t1.owner_user_id = t2.user_id WHERE t1.property_address_id = t2.user_address_id
1,073
real_estate_rentals
spider
List the search content of the users who do not own a single property.
test
hard
SELECT search_string FROM user_searches EXCEPT SELECT t1.search_string FROM user_searches AS t1 JOIN properties AS t2 ON t1.user_id = t2.owner_user_id
1,074
real_estate_rentals
spider
What search strings were entered by users who do not own any properties?
test
hard
SELECT search_string FROM user_searches EXCEPT SELECT t1.search_string FROM user_searches AS t1 JOIN properties AS t2 ON t1.user_id = t2.owner_user_id
1,075
real_estate_rentals
spider
List the last names and ids of users who have at least 2 properties and searched at most twice.
test
hard
SELECT t1.last_name, t1.user_id FROM users AS t1 JOIN user_searches AS t2 ON t1.user_id = t2.user_id GROUP BY t1.user_id HAVING COUNT(*) <= 2 INTERSECT SELECT t3.last_name, t3.user_id FROM users AS t3 JOIN properties AS t4 ON t3.user_id = t4.owner_user_id GROUP BY t3.user_id HAVING COUNT(*) >= 2
1,076
real_estate_rentals
spider
What are the last names and ids of users who have searched two or fewer times, and own two or more properties?
test
hard
SELECT t1.last_name, t1.user_id FROM users AS t1 JOIN user_searches AS t2 ON t1.user_id = t2.user_id GROUP BY t1.user_id HAVING COUNT(*) <= 2 INTERSECT SELECT t3.last_name, t3.user_id FROM users AS t3 JOIN properties AS t4 ON t3.user_id = t4.owner_user_id GROUP BY t3.user_id HAVING COUNT(*) >= 2
1,077
customers_card_transactions
spider
How many accounts do we have?
train
easy
SELECT COUNT(*) FROM accounts
1,078
customers_card_transactions
spider
Count the number of accounts.
train
easy
SELECT COUNT(*) FROM accounts
1,079
customers_card_transactions
spider
Show ids, customer ids, names for all accounts.
train
easy
SELECT account_id, customer_id, account_name FROM accounts
1,080
customers_card_transactions
spider
What are the account ids, customer ids, and account names for all the accounts?
train
easy
SELECT account_id, customer_id, account_name FROM accounts
1,081
customers_card_transactions
spider
Show other account details for account with name 338.
train
easy
SELECT other_account_details FROM accounts WHERE account_name = '338'
1,082
customers_card_transactions
spider
What are the other account details for the account with the name 338?
train
easy
SELECT other_account_details FROM accounts WHERE account_name = '338'
1,083
customers_card_transactions
spider
What is the first name, last name, and phone of the customer with account name 162?
train
hard
SELECT t2.customer_first_name, t2.customer_last_name, t2.customer_phone FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.account_name = '162'
1,084
customers_card_transactions
spider
Give the full name and phone of the customer who has the account name 162.
train
hard
SELECT t2.customer_first_name, t2.customer_last_name, t2.customer_phone FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.account_name = '162'
1,085
customers_card_transactions
spider
How many accounts does the customer with first name Art and last name Turcotte have?
train
hard
SELECT COUNT(*) FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_first_name = 'art' AND t2.customer_last_name = 'turcotte'
1,086
customers_card_transactions
spider
Return the number of accounts that the customer with the first name Art and last name Turcotte has.
train
hard
SELECT COUNT(*) FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_first_name = 'art' AND t2.customer_last_name = 'turcotte'
1,087
customers_card_transactions
spider
Show all customer ids and the number of accounts for each customer.
train
hard
SELECT customer_id, COUNT(*) FROM accounts GROUP BY customer_id
1,088
customers_card_transactions
spider
How many accounts are there for each customer id?
train
hard
SELECT customer_id, COUNT(*) FROM accounts GROUP BY customer_id
1,089
customers_card_transactions
spider
Show the customer id and number of accounts with most accounts.
train
hard
SELECT customer_id, COUNT(*) FROM accounts GROUP BY customer_id ORDER BY COUNT(*) DESC LIMIT 1
1,090
customers_card_transactions
spider
What is the customer id of the customer with the most accounts, and how many accounts does this person have?
train
hard
SELECT customer_id, COUNT(*) FROM accounts GROUP BY customer_id ORDER BY COUNT(*) DESC LIMIT 1
1,091
customers_card_transactions
spider
What is the customer first, last name and id with least number of accounts.
train
hard
SELECT t2.customer_first_name, t2.customer_last_name, t1.customer_id FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY COUNT(*) ASC LIMIT 1
1,092
customers_card_transactions
spider
Give the full name and customer id of the customer with the fewest accounts.
train
hard
SELECT t2.customer_first_name, t2.customer_last_name, t1.customer_id FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY COUNT(*) ASC LIMIT 1
1,093
customers_card_transactions
spider
Show the number of all customers without an account.
train
easy
SELECT COUNT(*) FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM accounts)
1,094
customers_card_transactions
spider
How many customers do not have an account?
train
easy
SELECT COUNT(*) FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM accounts)
1,095
customers_card_transactions
spider
Show the first names and last names of customers without any account.
train
hard
SELECT customer_first_name, customer_last_name FROM customers EXCEPT SELECT t1.customer_first_name, t1.customer_last_name FROM customers AS t1 JOIN accounts AS t2 ON t1.customer_id = t2.customer_id
1,096
customers_card_transactions
spider
What are the full names of customers who do not have any accounts?
train
hard
SELECT customer_first_name, customer_last_name FROM customers EXCEPT SELECT t1.customer_first_name, t1.customer_last_name FROM customers AS t1 JOIN accounts AS t2 ON t1.customer_id = t2.customer_id
1,097
customers_card_transactions
spider
Show distinct first and last names for all customers with an account.
train
hard
SELECT DISTINCT t1.customer_first_name, t1.customer_last_name FROM customers AS t1 JOIN accounts AS t2 ON t1.customer_id = t2.customer_id
1,098
customers_card_transactions
spider
What are the full names of customers who have accounts?
train
hard
SELECT DISTINCT t1.customer_first_name, t1.customer_last_name FROM customers AS t1 JOIN accounts AS t2 ON t1.customer_id = t2.customer_id
1,099
customers_card_transactions
spider
How many customers have an account?
train
easy
SELECT COUNT(DISTINCT customer_id) FROM accounts
1,100
customers_card_transactions
spider
Count the number of customers who hold an account.
train
easy
SELECT COUNT(DISTINCT customer_id) FROM accounts