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,301
insurance_and_eClaims
spider
Which type of policy is most frequently used? Give me the policy type code.
train
hard
SELECT policy_type_code FROM policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1
1,302
insurance_and_eClaims
spider
Find the type code of the most frequently used policy.
train
hard
SELECT policy_type_code FROM policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1
1,303
insurance_and_eClaims
spider
Find all the policy types that are used by more than 2 customers.
train
hard
SELECT policy_type_code FROM policies GROUP BY policy_type_code HAVING COUNT(*) > 2
1,304
insurance_and_eClaims
spider
Which types of policy are chosen by more than 2 customers? Give me the policy type codes.
train
hard
SELECT policy_type_code FROM policies GROUP BY policy_type_code HAVING COUNT(*) > 2
1,305
insurance_and_eClaims
spider
Find the total and average amount paid in claim headers.
train
easy
SELECT SUM(amount_piad), AVG(amount_piad) FROM claim_headers
1,306
insurance_and_eClaims
spider
What are the total amount and average amount paid in claim headers?
train
easy
SELECT SUM(amount_piad), AVG(amount_piad) FROM claim_headers
1,307
insurance_and_eClaims
spider
Find the total amount claimed in the most recently created document.
train
hard
SELECT SUM(t1.amount_claimed) FROM claim_headers AS t1 JOIN claims_documents AS t2 ON t1.claim_header_id = t2.claim_id WHERE t2.created_date = (SELECT created_date FROM claims_documents ORDER BY created_date LIMIT 1)
1,308
insurance_and_eClaims
spider
How much amount in total were claimed in the most recently created document?
train
hard
SELECT SUM(t1.amount_claimed) FROM claim_headers AS t1 JOIN claims_documents AS t2 ON t1.claim_header_id = t2.claim_id WHERE t2.created_date = (SELECT created_date FROM claims_documents ORDER BY created_date LIMIT 1)
1,309
insurance_and_eClaims
spider
What is the name of the customer who has made the largest amount of claim in a single claim?
train
hard
SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_claimed = (SELECT MAX(amount_claimed) FROM claim_headers)
1,310
insurance_and_eClaims
spider
Which customer made the largest amount of claim in a single claim? Return the customer details.
train
hard
SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_claimed = (SELECT MAX(amount_claimed) FROM claim_headers)
1,311
insurance_and_eClaims
spider
What is the name of the customer who has made the minimum amount of payment in one claim?
train
hard
SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_piad = (SELECT MIN(amount_piad) FROM claim_headers)
1,312
insurance_and_eClaims
spider
Which customer made the smallest amount of claim in one claim? Return the customer details.
train
hard
SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_piad = (SELECT MIN(amount_piad) FROM claim_headers)
1,313
insurance_and_eClaims
spider
Find the names of customers who have no policies associated.
train
hard
SELECT customer_details FROM customers EXCEPT SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id
1,314
insurance_and_eClaims
spider
What are the names of customers who do not have any policies?
train
hard
SELECT customer_details FROM customers EXCEPT SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id
1,315
insurance_and_eClaims
spider
How many claim processing stages are there in total?
train
easy
SELECT COUNT(*) FROM claims_processing_stages
1,316
insurance_and_eClaims
spider
Find the number of distinct stages in claim processing.
train
easy
SELECT COUNT(*) FROM claims_processing_stages
1,317
insurance_and_eClaims
spider
What is the name of the claim processing stage that most of the claims are on?
train
hard
SELECT t2.claim_status_name FROM claims_processing AS t1 JOIN claims_processing_stages AS t2 ON t1.claim_stage_id = t2.claim_stage_id GROUP BY t1.claim_stage_id ORDER BY COUNT(*) DESC LIMIT 1
1,318
insurance_and_eClaims
spider
Which claim processing stage has the most claims? Show the claim status name.
train
hard
SELECT t2.claim_status_name FROM claims_processing AS t1 JOIN claims_processing_stages AS t2 ON t1.claim_stage_id = t2.claim_stage_id GROUP BY t1.claim_stage_id ORDER BY COUNT(*) DESC LIMIT 1
1,319
insurance_and_eClaims
spider
Find the names of customers whose name contains "Diana".
train
easy
SELECT customer_details FROM customers WHERE customer_details LIKE '%diana%'
1,320
insurance_and_eClaims
spider
Which customers have the substring "Diana" in their names? Return the customer details.
train
easy
SELECT customer_details FROM customers WHERE customer_details LIKE '%diana%'
1,321
insurance_and_eClaims
spider
Find the names of the customers who have an deputy policy.
train
hard
SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = 'deputy'
1,322
insurance_and_eClaims
spider
Which customers have an insurance policy with the type code "Deputy"? Give me the customer details.
train
hard
SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = 'deputy'
1,323
insurance_and_eClaims
spider
Find the names of customers who either have an deputy policy or uniformed policy.
train
hard
SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = 'deputy' OR t1.policy_type_code = 'uniform'
1,324
insurance_and_eClaims
spider
Which customers have an insurance policy with the type code "Deputy" or "Uniform"? Return the customer details.
train
hard
SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = 'deputy' OR t1.policy_type_code = 'uniform'
1,325
insurance_and_eClaims
spider
Find the names of all the customers and staff members.
train
easy
SELECT customer_details FROM customers UNION SELECT staff_details FROM staff
1,326
insurance_and_eClaims
spider
What are the names of the customers and staff members?
train
easy
SELECT customer_details FROM customers UNION SELECT staff_details FROM staff
1,327
insurance_and_eClaims
spider
Find the number of records of each policy type and its type code.
train
hard
SELECT policy_type_code, COUNT(*) FROM policies GROUP BY policy_type_code
1,328
insurance_and_eClaims
spider
For each policy type, return its type code and its count in the record.
train
hard
SELECT policy_type_code, COUNT(*) FROM policies GROUP BY policy_type_code
1,329
insurance_and_eClaims
spider
Find the name of the customer that has been involved in the most policies.
train
hard
SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t2.customer_details ORDER BY COUNT(*) DESC LIMIT 1
1,330
insurance_and_eClaims
spider
Which customer have the most policies? Give me the customer details.
train
hard
SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t2.customer_details ORDER BY COUNT(*) DESC LIMIT 1
1,331
insurance_and_eClaims
spider
What is the description of the claim status "Open"?
train
easy
SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name = 'open'
1,332
insurance_and_eClaims
spider
Find the description of the claim status "Open".
train
easy
SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name = 'open'
1,333
insurance_and_eClaims
spider
How many distinct claim outcome codes are there?
train
easy
SELECT COUNT(DISTINCT claim_outcome_code) FROM claims_processing
1,334
insurance_and_eClaims
spider
Count the number of distinct claim outcome codes.
train
easy
SELECT COUNT(DISTINCT claim_outcome_code) FROM claims_processing
1,335
insurance_and_eClaims
spider
Which customer is associated with the latest policy?
train
hard
SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.start_date = (SELECT MAX(start_date) FROM policies)
1,336
insurance_and_eClaims
spider
Find the customer who started a policy most recently.
train
hard
SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.start_date = (SELECT MAX(start_date) FROM policies)
1,337
customers_and_invoices
spider
Show the number of accounts.
train
easy
SELECT COUNT(*) FROM accounts
1,338
customers_and_invoices
spider
How many accounts are there?
train
easy
SELECT COUNT(*) FROM accounts
1,339
customers_and_invoices
spider
How many customers have opened an account?
train
easy
SELECT COUNT(DISTINCT customer_id) FROM accounts
1,340
customers_and_invoices
spider
Count the number of customers who have an account.
train
easy
SELECT COUNT(DISTINCT customer_id) FROM accounts
1,341
customers_and_invoices
spider
Show the id, the date of account opened, the account name, and other account detail for all accounts.
train
easy
SELECT account_id, date_account_opened, account_name, other_account_details FROM accounts
1,342
customers_and_invoices
spider
What are the ids, date opened, name, and other details for all accounts?
train
easy
SELECT account_id, date_account_opened, account_name, other_account_details FROM accounts
1,343
customers_and_invoices
spider
Show the id, the account name, and other account details for all accounts by the customer with first name 'Meaghan'.
train
hard
SELECT t1.account_id, t1.date_account_opened, t1.account_name, t1.other_account_details FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_first_name = 'meaghan'
1,344
customers_and_invoices
spider
What are the ids, names, dates of opening, and other details for accounts corresponding to the customer with the first name "Meaghan"?
train
hard
SELECT t1.account_id, t1.date_account_opened, t1.account_name, t1.other_account_details FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_first_name = 'meaghan'
1,345
customers_and_invoices
spider
Show the account name and other account detail for all accounts by the customer with first name Meaghan and last name Keeling.
train
hard
SELECT t1.account_name, t1.other_account_details FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_first_name = 'meaghan' AND t2.customer_last_name = 'keeling'
1,346
customers_and_invoices
spider
What are the names and other details for accounts corresponding to the customer named Meaghan Keeling?
train
hard
SELECT t1.account_name, t1.other_account_details FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_first_name = 'meaghan' AND t2.customer_last_name = 'keeling'
1,347
customers_and_invoices
spider
Show the first name and last name for the customer with account name 900.
train
hard
SELECT t2.customer_first_name, t2.customer_last_name FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.account_name = '900'
1,348
customers_and_invoices
spider
What are the full names of customers with the account name 900?
train
hard
SELECT t2.customer_first_name, t2.customer_last_name FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.account_name = '900'
1,349
customers_and_invoices
spider
How many customers don't have an account?
train
easy
SELECT COUNT(*) FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM accounts)
1,350
customers_and_invoices
spider
Count the number of customers who do not have an account.
train
easy
SELECT COUNT(*) FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM accounts)
1,351
customers_and_invoices
spider
Show the unique first names, last names, and phone numbers for all customers with any account.
train
hard
SELECT DISTINCT t1.customer_first_name, t1.customer_last_name, t1.phone_number FROM customers AS t1 JOIN accounts AS t2 ON t1.customer_id = t2.customer_id
1,352
customers_and_invoices
spider
What are the distinct first names, last names, and phone numbers for customers with accounts?
train
hard
SELECT DISTINCT t1.customer_first_name, t1.customer_last_name, t1.phone_number FROM customers AS t1 JOIN accounts AS t2 ON t1.customer_id = t2.customer_id
1,353
customers_and_invoices
spider
Show customer ids who don't have an account.
train
easy
SELECT customer_id FROM customers EXCEPT SELECT customer_id FROM accounts
1,354
customers_and_invoices
spider
What are the customer ids for customers who do not have an account?
train
easy
SELECT customer_id FROM customers EXCEPT SELECT customer_id FROM accounts
1,355
customers_and_invoices
spider
How many accounts does each customer have? List the number and customer id.
train
hard
SELECT COUNT(*), customer_id FROM accounts GROUP BY customer_id
1,356
customers_and_invoices
spider
Count the number of accounts corresponding to each customer id.
train
hard
SELECT COUNT(*), customer_id FROM accounts GROUP BY customer_id
1,357
customers_and_invoices
spider
What is the customer id, first and last name with most number of accounts.
train
hard
SELECT t1.customer_id, t2.customer_first_name, t2.customer_last_name FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY COUNT(*) DESC LIMIT 1
1,358
customers_and_invoices
spider
Return the id and full name of the customer with the most accounts.
train
hard
SELECT t1.customer_id, t2.customer_first_name, t2.customer_last_name FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY COUNT(*) DESC LIMIT 1
1,359
customers_and_invoices
spider
Show id, first name and last name for all customers and the number of accounts.
train
hard
SELECT t1.customer_id, t2.customer_first_name, t2.customer_last_name, COUNT(*) FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id
1,360
customers_and_invoices
spider
What are the the full names and ids for all customers, and how many accounts does each have?
train
hard
SELECT t1.customer_id, t2.customer_first_name, t2.customer_last_name, COUNT(*) FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id
1,361
customers_and_invoices
spider
Show first name and id for all customers with at least 2 accounts.
train
hard
SELECT t2.customer_first_name, t1.customer_id FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id HAVING COUNT(*) >= 2
1,362
customers_and_invoices
spider
What are the first names and ids for customers who have two or more accounts?
train
hard
SELECT t2.customer_first_name, t1.customer_id FROM accounts AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id HAVING COUNT(*) >= 2
1,363
customers_and_invoices
spider
Show the number of customers.
train
easy
SELECT COUNT(*) FROM customers
1,364
customers_and_invoices
spider
Count the number of customers.
train
easy
SELECT COUNT(*) FROM customers
1,365
customers_and_invoices
spider
Show the number of customers for each gender.
train
hard
SELECT gender, COUNT(*) FROM customers GROUP BY gender
1,366
customers_and_invoices
spider
How many customers are there of each gender?
train
hard
SELECT gender, COUNT(*) FROM customers GROUP BY gender
1,367
customers_and_invoices
spider
How many transactions do we have?
train
easy
SELECT COUNT(*) FROM financial_transactions
1,368
customers_and_invoices
spider
Count the number of transactions.
train
easy
SELECT COUNT(*) FROM financial_transactions
1,369
customers_and_invoices
spider
How many transaction does each account have? Show the number and account id.
train
easy
SELECT COUNT(*), account_id FROM financial_transactions
1,370
customers_and_invoices
spider
Count the number of financial transactions that correspond to each account id.
train
easy
SELECT COUNT(*), account_id FROM financial_transactions
1,371
customers_and_invoices
spider
How many transaction does account with name 337 have?
train
hard
SELECT COUNT(*) FROM financial_transactions AS t1 JOIN accounts AS t2 ON t1.account_id = t2.account_id WHERE t2.account_name = '337'
1,372
customers_and_invoices
spider
Count the number of financial transactions that the account with the name 337 has.
train
hard
SELECT COUNT(*) FROM financial_transactions AS t1 JOIN accounts AS t2 ON t1.account_id = t2.account_id WHERE t2.account_name = '337'
1,373
customers_and_invoices
spider
What is the average, minimum, maximum, and total transaction amount?
train
easy
SELECT AVG(transaction_amount), MIN(transaction_amount), MAX(transaction_amount), SUM(transaction_amount) FROM financial_transactions
1,374
customers_and_invoices
spider
Return the average, minimum, maximum, and total transaction amounts.
train
easy
SELECT AVG(transaction_amount), MIN(transaction_amount), MAX(transaction_amount), SUM(transaction_amount) FROM financial_transactions
1,375
customers_and_invoices
spider
Show ids for all transactions whose amounts are greater than the average.
train
easy
SELECT transaction_id FROM financial_transactions WHERE transaction_amount > (SELECT AVG(transaction_amount) FROM financial_transactions)
1,376
customers_and_invoices
spider
What are the ids for transactions that have an amount greater than the average amount of a transaction?
train
easy
SELECT transaction_id FROM financial_transactions WHERE transaction_amount > (SELECT AVG(transaction_amount) FROM financial_transactions)
1,377
customers_and_invoices
spider
Show the transaction types and the total amount of transactions.
train
hard
SELECT transaction_type, SUM(transaction_amount) FROM financial_transactions GROUP BY transaction_type
1,378
customers_and_invoices
spider
What are total transaction amounts for each transaction type?
train
hard
SELECT transaction_type, SUM(transaction_amount) FROM financial_transactions GROUP BY transaction_type
1,379
customers_and_invoices
spider
Show the account name, id and the number of transactions for each account.
train
hard
SELECT t2.account_name, t1.account_id, COUNT(*) FROM financial_transactions AS t1 JOIN accounts AS t2 ON t1.account_id = t2.account_id GROUP BY t1.account_id
1,380
customers_and_invoices
spider
Return the names and ids of each account, as well as the number of transactions.
train
hard
SELECT t2.account_name, t1.account_id, COUNT(*) FROM financial_transactions AS t1 JOIN accounts AS t2 ON t1.account_id = t2.account_id GROUP BY t1.account_id
1,381
customers_and_invoices
spider
Show the account id with most number of transactions.
train
hard
SELECT account_id FROM financial_transactions GROUP BY account_id ORDER BY COUNT(*) DESC LIMIT 1
1,382
customers_and_invoices
spider
What is the id of the account with the most transactions?
train
hard
SELECT account_id FROM financial_transactions GROUP BY account_id ORDER BY COUNT(*) DESC LIMIT 1
1,383
customers_and_invoices
spider
Show the account id and name with at least 4 transactions.
train
hard
SELECT t1.account_id, t2.account_name FROM financial_transactions AS t1 JOIN accounts AS t2 ON t1.account_id = t2.account_id GROUP BY t1.account_id HAVING COUNT(*) >= 4
1,384
customers_and_invoices
spider
What are the ids and names of accounts with 4 or more transactions?
train
hard
SELECT t1.account_id, t2.account_name FROM financial_transactions AS t1 JOIN accounts AS t2 ON t1.account_id = t2.account_id GROUP BY t1.account_id HAVING COUNT(*) >= 4
1,385
customers_and_invoices
spider
Show all product sizes.
train
easy
SELECT DISTINCT product_size FROM products
1,386
customers_and_invoices
spider
What are the different product sizes?
train
easy
SELECT DISTINCT product_size FROM products
1,387
customers_and_invoices
spider
Show all product colors.
train
easy
SELECT DISTINCT product_color FROM products
1,388
customers_and_invoices
spider
What are the different product colors?
train
easy
SELECT DISTINCT product_color FROM products
1,389
customers_and_invoices
spider
Show the invoice number and the number of transactions for each invoice.
train
hard
SELECT invoice_number, COUNT(*) FROM financial_transactions GROUP BY invoice_number
1,390
customers_and_invoices
spider
How many transactions correspond to each invoice number?
train
hard
SELECT invoice_number, COUNT(*) FROM financial_transactions GROUP BY invoice_number
1,391
customers_and_invoices
spider
What is the invoice number and invoice date for the invoice with most number of transactions?
train
hard
SELECT t2.invoice_number, t2.invoice_date FROM financial_transactions AS t1 JOIN invoices AS t2 ON t1.invoice_number = t2.invoice_number GROUP BY t1.invoice_number ORDER BY COUNT(*) DESC LIMIT 1
1,392
customers_and_invoices
spider
What is the invoice number and invoice date corresponding to the invoice with the greatest number of transactions?
train
hard
SELECT t2.invoice_number, t2.invoice_date FROM financial_transactions AS t1 JOIN invoices AS t2 ON t1.invoice_number = t2.invoice_number GROUP BY t1.invoice_number ORDER BY COUNT(*) DESC LIMIT 1
1,393
customers_and_invoices
spider
How many invoices do we have?
train
easy
SELECT COUNT(*) FROM invoices
1,394
customers_and_invoices
spider
Count the number of invoices.
train
easy
SELECT COUNT(*) FROM invoices
1,395
customers_and_invoices
spider
Show invoice dates and order id and details for all invoices.
train
hard
SELECT t1.invoice_date, t1.order_id, t2.order_details FROM invoices AS t1 JOIN orders AS t2 ON t1.order_id = t2.order_id
1,396
customers_and_invoices
spider
What are the invoice dates, order ids, and order details for all invoices?
train
hard
SELECT t1.invoice_date, t1.order_id, t2.order_details FROM invoices AS t1 JOIN orders AS t2 ON t1.order_id = t2.order_id
1,397
customers_and_invoices
spider
Show the order ids and the number of invoices for each order.
train
hard
SELECT order_id, COUNT(*) FROM invoices GROUP BY order_id
1,398
customers_and_invoices
spider
How many invoices correspond to each order id?
train
hard
SELECT order_id, COUNT(*) FROM invoices GROUP BY order_id
1,399
customers_and_invoices
spider
What is the order id and order details for the order more than two invoices.
train
hard
SELECT t2.order_id, t2.order_details FROM invoices AS t1 JOIN orders AS t2 ON t1.order_id = t2.order_id GROUP BY t2.order_id HAVING COUNT(*) > 2
1,400
customers_and_invoices
spider
Return the order ids and details for orderes with two or more invoices.
train
hard
SELECT t2.order_id, t2.order_details FROM invoices AS t1 JOIN orders AS t2 ON t1.order_id = t2.order_id GROUP BY t2.order_id HAVING COUNT(*) > 2