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,101
customers_card_transactions
spider
How many customers do we have?
train
easy
SELECT COUNT(*) FROM customers
1,102
customers_card_transactions
spider
Count the number of customers.
train
easy
SELECT COUNT(*) FROM customers
1,103
customers_card_transactions
spider
Show ids, first names, last names, and phones for all customers.
train
easy
SELECT customer_id, customer_first_name, customer_last_name, customer_phone FROM customers
1,104
customers_card_transactions
spider
What are the ids, full names, and phones of each customer?
train
easy
SELECT customer_id, customer_first_name, customer_last_name, customer_phone FROM customers
1,105
customers_card_transactions
spider
What is the phone and email for customer with first name Aniyah and last name Feest?
train
medium
SELECT customer_phone, customer_email FROM customers WHERE customer_first_name = 'aniyah' AND customer_last_name = 'feest'
1,106
customers_card_transactions
spider
Return the phone and email of the customer with the first name Aniyah and last name Feest.
train
medium
SELECT customer_phone, customer_email FROM customers WHERE customer_first_name = 'aniyah' AND customer_last_name = 'feest'
1,107
customers_card_transactions
spider
Show the number of customer cards.
train
easy
SELECT COUNT(*) FROM customers_cards
1,108
customers_card_transactions
spider
How many customer cards are there?
train
easy
SELECT COUNT(*) FROM customers_cards
1,109
customers_card_transactions
spider
Show ids, customer ids, card type codes, card numbers for all cards.
train
easy
SELECT card_id, customer_id, card_type_code, card_number FROM customers_cards
1,110
customers_card_transactions
spider
What are card ids, customer ids, card types, and card numbers for each customer card?
train
easy
SELECT card_id, customer_id, card_type_code, card_number FROM customers_cards
1,111
customers_card_transactions
spider
Show the date valid from and the date valid to for the card with card number '4560596484842'.
train
easy
SELECT date_valid_from, date_valid_to FROM customers_cards WHERE card_number = '4560596484842'
1,112
customers_card_transactions
spider
What are the valid from and valid to dates for the card with the number 4560596484842?
train
easy
SELECT date_valid_from, date_valid_to FROM customers_cards WHERE card_number = '4560596484842'
1,113
customers_card_transactions
spider
What is the first name, last name, and phone of the customer with card 4560596484842.
train
hard
SELECT t2.customer_first_name, t2.customer_last_name, t2.customer_phone FROM customers_cards AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.card_number = '4560596484842'
1,114
customers_card_transactions
spider
Return the full name and phone of the customer who has card number 4560596484842.
train
hard
SELECT t2.customer_first_name, t2.customer_last_name, t2.customer_phone FROM customers_cards AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.card_number = '4560596484842'
1,115
customers_card_transactions
spider
How many cards does customer Art Turcotte have?
train
hard
SELECT COUNT(*) FROM customers_cards 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,116
customers_card_transactions
spider
Count the number of cards the customer with the first name Art and last name Turcotte has.
train
hard
SELECT COUNT(*) FROM customers_cards 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,117
customers_card_transactions
spider
How many debit cards do we have?
train
easy
SELECT COUNT(*) FROM customers_cards WHERE card_type_code = 'debit'
1,118
customers_card_transactions
spider
Count the number of customer cards of the type Debit.
train
easy
SELECT COUNT(*) FROM customers_cards WHERE card_type_code = 'debit'
1,119
customers_card_transactions
spider
How many credit cards does customer Blanche Huels have?
train
hard
SELECT COUNT(*) FROM customers_cards AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_first_name = 'blanche' AND t2.customer_last_name = 'huels' AND t1.card_type_code = 'credit'
1,120
customers_card_transactions
spider
Count the number of credit cards that the customer with first name Blanche and last name Huels has.
train
hard
SELECT COUNT(*) FROM customers_cards AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_first_name = 'blanche' AND t2.customer_last_name = 'huels' AND t1.card_type_code = 'credit'
1,121
customers_card_transactions
spider
Show all customer ids and the number of cards owned by each customer.
train
hard
SELECT customer_id, COUNT(*) FROM customers_cards GROUP BY customer_id
1,122
customers_card_transactions
spider
What are the different customer ids, and how many cards does each one hold?
train
hard
SELECT customer_id, COUNT(*) FROM customers_cards GROUP BY customer_id
1,123
customers_card_transactions
spider
What is the customer id with most number of cards, and how many does he have?
train
hard
SELECT customer_id, COUNT(*) FROM customers_cards GROUP BY customer_id ORDER BY COUNT(*) DESC LIMIT 1
1,124
customers_card_transactions
spider
Return the id of the customer who has the most cards, as well as the number of cards.
train
hard
SELECT customer_id, COUNT(*) FROM customers_cards GROUP BY customer_id ORDER BY COUNT(*) DESC LIMIT 1
1,125
customers_card_transactions
spider
Show id, first and last names for all customers with at least two cards.
train
hard
SELECT t1.customer_id, t2.customer_first_name, t2.customer_last_name FROM customers_cards AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id HAVING COUNT(*) >= 2
1,126
customers_card_transactions
spider
What are the ids and full names of customers who hold two or more cards?
train
hard
SELECT t1.customer_id, t2.customer_first_name, t2.customer_last_name FROM customers_cards AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id HAVING COUNT(*) >= 2
1,127
customers_card_transactions
spider
What is the customer id, first and last name with least number of accounts.
train
hard
SELECT t1.customer_id, t2.customer_first_name, t2.customer_last_name FROM customers_cards 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,128
customers_card_transactions
spider
Return the id and full name of the customer who has the fewest accounts.
train
hard
SELECT t1.customer_id, t2.customer_first_name, t2.customer_last_name FROM customers_cards 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,129
customers_card_transactions
spider
Show all card type codes and the number of cards in each type.
train
hard
SELECT card_type_code, COUNT(*) FROM customers_cards GROUP BY card_type_code
1,130
customers_card_transactions
spider
What are the different card types, and how many cards are there of each?
train
hard
SELECT card_type_code, COUNT(*) FROM customers_cards GROUP BY card_type_code
1,131
customers_card_transactions
spider
What is the card type code with most number of cards?
train
hard
SELECT card_type_code FROM customers_cards GROUP BY card_type_code ORDER BY COUNT(*) DESC LIMIT 1
1,132
customers_card_transactions
spider
Return the code of the card type that is most common.
train
hard
SELECT card_type_code FROM customers_cards GROUP BY card_type_code ORDER BY COUNT(*) DESC LIMIT 1
1,133
customers_card_transactions
spider
Show card type codes with at least 5 cards.
train
hard
SELECT card_type_code FROM customers_cards GROUP BY card_type_code HAVING COUNT(*) >= 5
1,134
customers_card_transactions
spider
What are the codes of card types that have 5 or more cards?
train
hard
SELECT card_type_code FROM customers_cards GROUP BY card_type_code HAVING COUNT(*) >= 5
1,135
customers_card_transactions
spider
Show all card type codes and the number of customers holding cards in each type.
train
hard
SELECT card_type_code, COUNT(DISTINCT customer_id) FROM customers_cards GROUP BY card_type_code
1,136
customers_card_transactions
spider
What are the different card type codes, and how many different customers hold each type?
train
hard
SELECT card_type_code, COUNT(DISTINCT customer_id) FROM customers_cards GROUP BY card_type_code
1,137
customers_card_transactions
spider
Show the customer ids and firstname without a credit card.
train
hard
SELECT customer_id, customer_first_name FROM customers EXCEPT SELECT t1.customer_id, t2.customer_first_name FROM customers_cards AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE card_type_code = 'credit'
1,138
customers_card_transactions
spider
What are the ids and first names of customers who do not hold a credit card?
train
hard
SELECT customer_id, customer_first_name FROM customers EXCEPT SELECT t1.customer_id, t2.customer_first_name FROM customers_cards AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE card_type_code = 'credit'
1,139
customers_card_transactions
spider
Show all card type codes.
train
easy
SELECT DISTINCT card_type_code FROM customers_cards
1,140
customers_card_transactions
spider
What are the different card type codes?
train
easy
SELECT DISTINCT card_type_code FROM customers_cards
1,141
customers_card_transactions
spider
Show the number of card types.
train
easy
SELECT COUNT(DISTINCT card_type_code) FROM customers_cards
1,142
customers_card_transactions
spider
How many different card types are there?
train
easy
SELECT COUNT(DISTINCT card_type_code) FROM customers_cards
1,143
customers_card_transactions
spider
Show all transaction types.
train
easy
SELECT DISTINCT transaction_type FROM financial_transactions
1,144
customers_card_transactions
spider
What are the different types of transactions?
train
easy
SELECT DISTINCT transaction_type FROM financial_transactions
1,145
customers_card_transactions
spider
Show the number of transaction types.
train
easy
SELECT COUNT(DISTINCT transaction_type) FROM financial_transactions
1,146
customers_card_transactions
spider
How many different types of transactions are there?
train
easy
SELECT COUNT(DISTINCT transaction_type) FROM financial_transactions
1,147
customers_card_transactions
spider
What is the average and total transaction amount?
train
easy
SELECT AVG(transaction_amount), SUM(transaction_amount) FROM financial_transactions
1,148
customers_card_transactions
spider
Return the average transaction amount, as well as the total amount of all transactions.
train
easy
SELECT AVG(transaction_amount), SUM(transaction_amount) FROM financial_transactions
1,149
customers_card_transactions
spider
Show the card type codes and the number of transactions.
train
hard
SELECT t2.card_type_code, COUNT(*) FROM financial_transactions AS t1 JOIN customers_cards AS t2 ON t1.card_id = t2.card_id GROUP BY t2.card_type_code
1,150
customers_card_transactions
spider
What are the different card types, and how many transactions have been made with each?
train
hard
SELECT t2.card_type_code, COUNT(*) FROM financial_transactions AS t1 JOIN customers_cards AS t2 ON t1.card_id = t2.card_id GROUP BY t2.card_type_code
1,151
customers_card_transactions
spider
Show the transaction type and the number of transactions.
train
hard
SELECT transaction_type, COUNT(*) FROM financial_transactions GROUP BY transaction_type
1,152
customers_card_transactions
spider
What are the different transaction types, and how many transactions of each have taken place?
train
hard
SELECT transaction_type, COUNT(*) FROM financial_transactions GROUP BY transaction_type
1,153
customers_card_transactions
spider
What is the transaction type that has processed the greatest total amount in transactions?
train
hard
SELECT transaction_type FROM financial_transactions GROUP BY transaction_type ORDER BY SUM(transaction_amount) DESC LIMIT 1
1,154
customers_card_transactions
spider
Return the type of transaction with the highest total amount.
train
hard
SELECT transaction_type FROM financial_transactions GROUP BY transaction_type ORDER BY SUM(transaction_amount) DESC LIMIT 1
1,155
customers_card_transactions
spider
Show the account id and the number of transactions for each account
train
hard
SELECT account_id, COUNT(*) FROM financial_transactions GROUP BY account_id
1,156
customers_card_transactions
spider
What are the different account ids that have made financial transactions, as well as how many transactions correspond to each?
train
hard
SELECT account_id, COUNT(*) FROM financial_transactions GROUP BY account_id
1,157
coffee_shop
spider
How many members have the black membership card?
train
easy
SELECT COUNT(*) FROM member WHERE membership_card = 'black'
1,158
coffee_shop
spider
Find the number of members living in each address.
train
hard
SELECT COUNT(*), address FROM member GROUP BY address
1,159
coffee_shop
spider
Give me the names of members whose address is in Harford or Waterbury.
train
medium
SELECT name FROM member WHERE address = 'harford' OR address = 'waterbury'
1,160
coffee_shop
spider
Find the ids and names of members who are under age 30 or with black membership card.
train
medium
SELECT name, member_id FROM member WHERE membership_card = 'black' OR age < 30
1,161
coffee_shop
spider
Find the purchase time, age and address of each member, and show the results in the order of purchase time.
train
hard
SELECT time_of_purchase, age, address FROM member ORDER BY time_of_purchase
1,162
coffee_shop
spider
Which membership card has more than 5 members?
train
hard
SELECT membership_card FROM member GROUP BY membership_card HAVING COUNT(*) > 5
1,163
coffee_shop
spider
Which address has both members younger than 30 and members older than 40?
train
easy
SELECT address FROM member WHERE age < 30 INTERSECT SELECT address FROM member WHERE age > 40
1,164
coffee_shop
spider
What is the membership card held by both members living in Hartford and ones living in Waterbury address?
train
medium
SELECT membership_card FROM member WHERE address = 'hartford' INTERSECT SELECT membership_card FROM member WHERE address = 'waterbury'
1,165
coffee_shop
spider
How many members are not living in Hartford?
train
medium
SELECT COUNT(*) FROM member WHERE address <> 'hartford'
1,166
coffee_shop
spider
Which address do not have any member with the black membership card?
train
easy
SELECT address FROM member EXCEPT SELECT address FROM member WHERE membership_card = 'black'
1,167
coffee_shop
spider
Show the shop addresses ordered by their opening year.
train
hard
SELECT address FROM shop ORDER BY open_year
1,168
coffee_shop
spider
What are the average score and average staff number of all shops?
train
easy
SELECT AVG(num_of_staff), AVG(score) FROM shop
1,169
coffee_shop
spider
Find the id and address of the shops whose score is below the average score.
train
medium
SELECT shop_id, address FROM shop WHERE score < (SELECT AVG(score) FROM shop)
1,170
coffee_shop
spider
Find the address and staff number of the shops that do not have any happy hour.
train
easy
SELECT address, num_of_staff FROM shop WHERE NOT shop_id IN (SELECT shop_id FROM happy_hour)
1,171
coffee_shop
spider
What are the id and address of the shops which have a happy hour in May?
train
hard
SELECT t1.address, t1.shop_id FROM shop AS t1 JOIN happy_hour AS t2 ON t1.shop_id = t2.shop_id WHERE month = 'may'
1,172
coffee_shop
spider
which shop has happy hour most frequently? List its id and number of happy hours.
train
hard
SELECT shop_id, COUNT(*) FROM happy_hour GROUP BY shop_id ORDER BY COUNT(*) DESC LIMIT 1
1,173
coffee_shop
spider
Which month has the most happy hours?
train
hard
SELECT month FROM happy_hour GROUP BY month ORDER BY COUNT(*) DESC LIMIT 1
1,174
coffee_shop
spider
Which months have more than 2 happy hours?
train
hard
SELECT month FROM happy_hour GROUP BY month HAVING COUNT(*) > 2
1,175
insurance_fnol
spider
Find all the phone numbers.
train
easy
SELECT customer_phone FROM available_policies
1,176
insurance_fnol
spider
What are all the phone numbers?
train
easy
SELECT customer_phone FROM available_policies
1,177
insurance_fnol
spider
What are the customer phone numbers under the policy "Life Insurance"?
train
easy
SELECT customer_phone FROM available_policies WHERE policy_type_code = 'life insurance'
1,178
insurance_fnol
spider
What are the phone numbers of customers using the policy with the code "Life Insurance"?
train
easy
SELECT customer_phone FROM available_policies WHERE policy_type_code = 'life insurance'
1,179
insurance_fnol
spider
Which policy type has the most records in the database?
train
hard
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1
1,180
insurance_fnol
spider
Which policy type appears most frequently in the available policies?
train
hard
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1
1,181
insurance_fnol
spider
What are all the customer phone numbers under the most popular policy type?
train
easy
SELECT customer_phone FROM available_policies WHERE policy_type_code = (SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1)
1,182
insurance_fnol
spider
Find the phone numbers of customers using the most common policy type among the available policies.
train
easy
SELECT customer_phone FROM available_policies WHERE policy_type_code = (SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1)
1,183
insurance_fnol
spider
Find the policy type used by more than 4 customers.
train
hard
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code HAVING COUNT(*) > 4
1,184
insurance_fnol
spider
Find the policy types more than 4 customers use. Show their type code.
train
hard
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code HAVING COUNT(*) > 4
1,185
insurance_fnol
spider
Find the total and average amount of settlements.
train
easy
SELECT SUM(settlement_amount), AVG(settlement_amount) FROM settlements
1,186
insurance_fnol
spider
Return the sum and average of all settlement amounts.
train
easy
SELECT SUM(settlement_amount), AVG(settlement_amount) FROM settlements
1,187
insurance_fnol
spider
Find the name of services that have been used for more than 2 times in first notification of loss.
train
hard
SELECT t2.service_name FROM first_notification_of_loss AS t1 JOIN services AS t2 ON t1.service_id = t2.service_id GROUP BY t1.service_id HAVING COUNT(*) > 2
1,188
insurance_fnol
spider
Which services have been used more than twice in first notification of loss? Return the service name.
train
hard
SELECT t2.service_name FROM first_notification_of_loss AS t1 JOIN services AS t2 ON t1.service_id = t2.service_id GROUP BY t1.service_id HAVING COUNT(*) > 2
1,189
insurance_fnol
spider
What is the effective date of the claim that has the largest amount of total settlement?
train
hard
SELECT t1.effective_date FROM claims AS t1 JOIN settlements AS t2 ON t1.claim_id = t2.claim_id GROUP BY t1.claim_id ORDER BY SUM(t2.settlement_amount) DESC LIMIT 1
1,190
insurance_fnol
spider
Find the claim that has the largest total settlement amount. Return the effective date of the claim.
train
hard
SELECT t1.effective_date FROM claims AS t1 JOIN settlements AS t2 ON t1.claim_id = t2.claim_id GROUP BY t1.claim_id ORDER BY SUM(t2.settlement_amount) DESC LIMIT 1
1,191
insurance_fnol
spider
How many policies are listed for the customer named "Dayana Robel"?
train
hard
SELECT COUNT(*) FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = 'dayana robel'
1,192
insurance_fnol
spider
Count the total number of policies used by the customer named "Dayana Robel".
train
hard
SELECT COUNT(*) FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = 'dayana robel'
1,193
insurance_fnol
spider
What is the name of the customer who has the most policies listed?
train
hard
SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_name ORDER BY COUNT(*) DESC LIMIT 1
1,194
insurance_fnol
spider
Which customer uses the most policies? Give me the customer name.
train
hard
SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_name ORDER BY COUNT(*) DESC LIMIT 1
1,195
insurance_fnol
spider
What are all the policy types of the customer named "Dayana Robel"?
train
hard
SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id JOIN available_policies AS t3 ON t2.policy_id = t3.policy_id WHERE t1.customer_name = 'dayana robel'
1,196
insurance_fnol
spider
Tell me the types of the policy used by the customer named "Dayana Robel".
train
hard
SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id JOIN available_policies AS t3 ON t2.policy_id = t3.policy_id WHERE t1.customer_name = 'dayana robel'
1,197
insurance_fnol
spider
What are all the policy types of the customer that has the most policies listed?
train
hard
SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id JOIN available_policies AS t3 ON t2.policy_id = t3.policy_id WHERE t1.customer_name = (SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id G...
1,198
insurance_fnol
spider
List all the policy types used by the customer enrolled in the most policies.
train
hard
SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id JOIN available_policies AS t3 ON t2.policy_id = t3.policy_id WHERE t1.customer_name = (SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id G...
1,199
insurance_fnol
spider
List all the services in the alphabetical order.
train
hard
SELECT service_name FROM services ORDER BY service_name
1,200
insurance_fnol
spider
Give me a list of all the service names sorted alphabetically.
train
hard
SELECT service_name FROM services ORDER BY service_name