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,501 | restaurant_1 | spider | What is the age of student Linda Smith? | train | medium | SELECT age FROM student WHERE fname = 'linda' AND lname = 'smith' |
1,502 | restaurant_1 | spider | What is the gender of the student Linda Smith? | train | medium | SELECT sex FROM student WHERE fname = 'linda' AND lname = 'smith' |
1,503 | restaurant_1 | spider | List all students' first names and last names who majored in 600. | train | medium | SELECT fname, lname FROM student WHERE major = 600 |
1,504 | restaurant_1 | spider | Which city does student Linda Smith live in? | train | medium | SELECT city_code FROM student WHERE fname = 'linda' AND lname = 'smith' |
1,505 | restaurant_1 | spider | Advisor 1121 has how many students? | train | medium | SELECT COUNT(*) FROM student WHERE advisor = 1121 |
1,506 | restaurant_1 | spider | Which Advisor has most of students? List advisor and the number of students. | train | hard | SELECT advisor, COUNT(*) FROM student GROUP BY advisor ORDER BY COUNT(advisor) DESC LIMIT 1 |
1,507 | restaurant_1 | spider | Which major has least number of students? List the major and the number of students. | train | hard | SELECT major, COUNT(*) FROM student GROUP BY major ORDER BY COUNT(major) ASC LIMIT 1 |
1,508 | restaurant_1 | spider | Which major has between 2 and 30 number of students? List major and the number of students. | train | hard | SELECT major, COUNT(*) FROM student GROUP BY major HAVING COUNT(major) BETWEEN 2 AND 30 |
1,509 | restaurant_1 | spider | Which student's age is older than 18 and is majoring in 600? List each student's first and last name. | train | medium | SELECT fname, lname FROM student WHERE age > 18 AND major = 600 |
1,510 | restaurant_1 | spider | List all female students age is older than 18 who is not majoring in 600. List students' first name and last name. | train | medium | SELECT fname, lname FROM student WHERE age > 18 AND major <> 600 AND sex = 'f' |
1,511 | restaurant_1 | spider | How many restaurant is the Sandwich type restaurant? | train | hard | SELECT COUNT(*) FROM restaurant JOIN type_of_restaurant ON restaurant.resid = type_of_restaurant.resid JOIN restaurant_type ON type_of_restaurant.restypeid = restaurant_type.restypeid GROUP BY type_of_restaurant.restypeid HAVING restaurant_type.restypename = 'sandwich' |
1,512 | restaurant_1 | spider | How long does student Linda Smith spend on the restaurant in total? | train | hard | SELECT SUM(spent) FROM student JOIN visits_restaurant ON student.stuid = visits_restaurant.stuid WHERE student.fname = 'linda' AND student.lname = 'smith' |
1,513 | restaurant_1 | spider | How many times has the student Linda Smith visited Subway? | train | hard | SELECT COUNT(*) FROM student JOIN visits_restaurant ON student.stuid = visits_restaurant.stuid JOIN restaurant ON visits_restaurant.resid = restaurant.resid WHERE student.fname = 'linda' AND student.lname = 'smith' AND restaurant.resname = 'subway' |
1,514 | restaurant_1 | spider | When did Linda Smith visit Subway? | train | hard | SELECT time FROM student JOIN visits_restaurant ON student.stuid = visits_restaurant.stuid JOIN restaurant ON visits_restaurant.resid = restaurant.resid WHERE student.fname = 'linda' AND student.lname = 'smith' AND restaurant.resname = 'subway' |
1,515 | restaurant_1 | spider | At which restaurant did the students spend the least amount of time? List restaurant and the time students spent on in total. | train | hard | SELECT restaurant.resname, SUM(visits_restaurant.spent) FROM visits_restaurant JOIN restaurant ON visits_restaurant.resid = restaurant.resid GROUP BY restaurant.resid ORDER BY SUM(visits_restaurant.spent) ASC LIMIT 1 |
1,516 | restaurant_1 | spider | Which student visited restaurant most often? List student's first name and last name. | train | hard | SELECT student.fname, student.lname FROM student JOIN visits_restaurant ON student.stuid = visits_restaurant.stuid GROUP BY student.stuid ORDER BY COUNT(*) DESC LIMIT 1 |
1,517 | customer_deliveries | spider | Find the ids of orders whose status is 'Success'. | train | medium | SELECT actual_order_id FROM actual_orders WHERE order_status_code = 'success' |
1,518 | customer_deliveries | spider | Find the name and price of the product that has been ordered the greatest number of times. | train | hard | SELECT t1.product_name, t1.product_price FROM products AS t1 JOIN regular_order_products AS t2 ON t1.product_id = t2.product_id GROUP BY t2.product_id ORDER BY COUNT(*) DESC LIMIT 1 |
1,519 | customer_deliveries | spider | Find the number of customers in total. | train | easy | SELECT COUNT(*) FROM customers |
1,520 | customer_deliveries | spider | How many different payment methods are there? | train | easy | SELECT COUNT(DISTINCT payment_method) FROM customers |
1,521 | customer_deliveries | spider | Show the details of all trucks in the order of their license number. | train | hard | SELECT truck_details FROM trucks ORDER BY truck_licence_number |
1,522 | customer_deliveries | spider | Find the name of the most expensive product. | train | hard | SELECT product_name FROM products ORDER BY product_price DESC LIMIT 1 |
1,523 | customer_deliveries | spider | Find the names of customers who are not living in the state of California. | train | hard | SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t3.state_province_county = 'california' |
1,524 | customer_deliveries | spider | List the names and emails of customers who payed by Visa card. | train | easy | SELECT customer_email, customer_name FROM customers WHERE payment_method = 'visa' |
1,525 | customer_deliveries | spider | Find the names and phone numbers of customers living in California state. | train | hard | SELECT t1.customer_name, t1.customer_phone FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t3.state_province_county = 'california' |
1,526 | customer_deliveries | spider | Find the states which do not have any employee in their record. | train | easy | SELECT state_province_county FROM addresses WHERE NOT address_id IN (SELECT employee_address_id FROM employees) |
1,527 | customer_deliveries | spider | List the names, phone numbers, and emails of all customers sorted by their dates of becoming customers. | train | hard | SELECT customer_name, customer_phone, customer_email FROM customers ORDER BY date_became_customer |
1,528 | customer_deliveries | spider | Find the name of the first 5 customers. | train | hard | SELECT customer_name FROM customers ORDER BY date_became_customer LIMIT 5 |
1,529 | customer_deliveries | spider | Find the payment method that is used most frequently. | train | hard | SELECT payment_method FROM customers GROUP BY payment_method ORDER BY COUNT(*) DESC LIMIT 1 |
1,530 | customer_deliveries | spider | List the names of all routes in alphabetic order. | train | hard | SELECT route_name FROM delivery_routes ORDER BY route_name |
1,531 | customer_deliveries | spider | Find the name of route that has the highest number of deliveries. | train | hard | SELECT t1.route_name FROM delivery_routes AS t1 JOIN delivery_route_locations AS t2 ON t1.route_id = t2.route_id GROUP BY t1.route_id ORDER BY COUNT(*) DESC LIMIT 1 |
1,532 | customer_deliveries | spider | List the state names and the number of customers living in each state. | train | hard | SELECT t2.state_province_county, COUNT(*) FROM customer_addresses AS t1 JOIN addresses AS t2 ON t1.address_id = t2.address_id GROUP BY t2.state_province_county |
1,533 | loan_1 | spider | How many bank branches are there? | train | easy | SELECT COUNT(*) FROM bank |
1,534 | loan_1 | spider | Count the number of bank branches. | train | easy | SELECT COUNT(*) FROM bank |
1,535 | loan_1 | spider | How many customers are there? | train | easy | SELECT SUM(no_of_customers) FROM bank |
1,536 | loan_1 | spider | What is the total number of customers across banks? | train | easy | SELECT SUM(no_of_customers) FROM bank |
1,537 | loan_1 | spider | Find the number of customers in the banks at New York City. | train | medium | SELECT SUM(no_of_customers) FROM bank WHERE city = 'new york city' |
1,538 | loan_1 | spider | What is the total number of customers who use banks in New York City? | train | medium | SELECT SUM(no_of_customers) FROM bank WHERE city = 'new york city' |
1,539 | loan_1 | spider | Find the average number of customers in all banks of Utah state. | train | easy | SELECT AVG(no_of_customers) FROM bank WHERE state = 'utah' |
1,540 | loan_1 | spider | What is the average number of customers across banks in the state of Utah? | train | easy | SELECT AVG(no_of_customers) FROM bank WHERE state = 'utah' |
1,541 | loan_1 | spider | Find the average number of customers cross all banks. | train | easy | SELECT AVG(no_of_customers) FROM bank |
1,542 | loan_1 | spider | What is the average number of bank customers? | train | easy | SELECT AVG(no_of_customers) FROM bank |
1,543 | loan_1 | spider | Find the city and state of the bank branch named morningside. | train | medium | SELECT city, state FROM bank WHERE bname = 'morningside' |
1,544 | loan_1 | spider | What city and state is the bank with the name morningside in? | train | medium | SELECT city, state FROM bank WHERE bname = 'morningside' |
1,545 | loan_1 | spider | Find the branch names of banks in the New York state. | train | medium | SELECT bname FROM bank WHERE state = 'new york' |
1,546 | loan_1 | spider | What are the names of banks in the state of New York? | train | medium | SELECT bname FROM bank WHERE state = 'new york' |
1,547 | loan_1 | spider | List the name of all customers sorted by their account balance in ascending order. | train | hard | SELECT cust_name FROM customer ORDER BY acc_bal |
1,548 | loan_1 | spider | What are the names of all customers, ordered by account balance? | train | hard | SELECT cust_name FROM customer ORDER BY acc_bal |
1,549 | loan_1 | spider | List the name of all different customers who have some loan sorted by their total loan amount. | train | hard | SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id GROUP BY t1.cust_name ORDER BY SUM(t2.amount) |
1,550 | loan_1 | spider | What are the names of the different customers who have taken out a loan, ordered by the total amount that they have taken? | train | hard | SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id GROUP BY t1.cust_name ORDER BY SUM(t2.amount) |
1,551 | loan_1 | spider | Find the state, account type, and credit score of the customer whose number of loan is 0. | train | easy | SELECT state, acc_type, credit_score FROM customer WHERE no_of_loans = 0 |
1,552 | loan_1 | spider | What are the states, account types, and credit scores for customers who have 0 loans? | train | easy | SELECT state, acc_type, credit_score FROM customer WHERE no_of_loans = 0 |
1,553 | loan_1 | spider | Find the number of different cities which banks are located at. | train | easy | SELECT COUNT(DISTINCT city) FROM bank |
1,554 | loan_1 | spider | In how many different cities are banks located? | train | easy | SELECT COUNT(DISTINCT city) FROM bank |
1,555 | loan_1 | spider | Find the number of different states which banks are located at. | train | easy | SELECT COUNT(DISTINCT state) FROM bank |
1,556 | loan_1 | spider | In how many different states are banks located? | train | easy | SELECT COUNT(DISTINCT state) FROM bank |
1,557 | loan_1 | spider | How many distinct types of accounts are there? | train | easy | SELECT COUNT(DISTINCT acc_type) FROM customer |
1,558 | loan_1 | spider | Count the number of different account types. | train | easy | SELECT COUNT(DISTINCT acc_type) FROM customer |
1,559 | loan_1 | spider | Find the name and account balance of the customer whose name includes the letter ‘a’. | train | easy | SELECT cust_name, acc_bal FROM customer WHERE cust_name LIKE '%a%' |
1,560 | loan_1 | spider | What are the names and account balances of customers with the letter a in their names? | train | easy | SELECT cust_name, acc_bal FROM customer WHERE cust_name LIKE '%a%' |
1,561 | loan_1 | spider | Find the total account balance of each customer from Utah or Texas. | train | medium | SELECT SUM(acc_bal) FROM customer WHERE state = 'utah' OR state = 'texas' |
1,562 | loan_1 | spider | What are the total account balances for each customer from Utah or Texas? | train | medium | SELECT SUM(acc_bal) FROM customer WHERE state = 'utah' OR state = 'texas' |
1,563 | loan_1 | spider | Find the name of customers who have both saving and checking account types. | train | easy | SELECT cust_name FROM customer WHERE acc_type = 'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type = 'checking' |
1,564 | loan_1 | spider | What are the names of customers who have both savings and checking accounts? | train | easy | SELECT cust_name FROM customer WHERE acc_type = 'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type = 'checking' |
1,565 | loan_1 | spider | Find the name of customers who do not have an saving account. | train | easy | SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving' |
1,566 | loan_1 | spider | What are the names of customers who do not have saving accounts? | train | easy | SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving' |
1,567 | loan_1 | spider | Find the name of customers who do not have a loan with a type of Mortgages. | train | hard | SELECT cust_name FROM customer EXCEPT SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id WHERE t2.loan_type = 'mortgages' |
1,568 | loan_1 | spider | What are the names of customers who have not taken a Mortage loan? | train | hard | SELECT cust_name FROM customer EXCEPT SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id WHERE t2.loan_type = 'mortgages' |
1,569 | loan_1 | spider | Find the name of customers who have loans of both Mortgages and Auto. | train | hard | SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id WHERE loan_type = 'mortgages' INTERSECT SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id WHERE loan_type = 'auto' |
1,570 | loan_1 | spider | What are the names of customers who have taken both Mortgage and Auto loans? | train | hard | SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id WHERE loan_type = 'mortgages' INTERSECT SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id WHERE loan_type = 'auto' |
1,571 | loan_1 | spider | Find the name of customers whose credit score is below the average credit scores of all customers. | train | medium | SELECT cust_name FROM customer WHERE credit_score < (SELECT AVG(credit_score) FROM customer) |
1,572 | loan_1 | spider | What are the names of customers with credit score less than the average credit score across customers? | train | medium | SELECT cust_name FROM customer WHERE credit_score < (SELECT AVG(credit_score) FROM customer) |
1,573 | loan_1 | spider | Find the branch name of the bank that has the most number of customers. | train | hard | SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1 |
1,574 | loan_1 | spider | What is the name of the bank branch with the greatest number of customers? | train | hard | SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1 |
1,575 | loan_1 | spider | Find the name of customer who has the lowest credit score. | train | hard | SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1 |
1,576 | loan_1 | spider | What is the name of the customer with the worst credit score? | train | hard | SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1 |
1,577 | loan_1 | spider | Find the name, account type, and account balance of the customer who has the highest credit score. | train | hard | SELECT cust_name, acc_type, acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1 |
1,578 | loan_1 | spider | What is the name, account type, and account balance corresponding to the customer with the highest credit score? | train | hard | SELECT cust_name, acc_type, acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1 |
1,579 | loan_1 | spider | Find the name of customer who has the highest amount of loans. | train | hard | SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id GROUP BY t1.cust_name ORDER BY SUM(t2.amount) DESC LIMIT 1 |
1,580 | loan_1 | spider | What is the name of the customer who has greatest total loan amount? | train | hard | SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id GROUP BY t1.cust_name ORDER BY SUM(t2.amount) DESC LIMIT 1 |
1,581 | loan_1 | spider | Find the state which has the most number of customers. | train | hard | SELECT state FROM bank GROUP BY state ORDER BY SUM(no_of_customers) DESC LIMIT 1 |
1,582 | loan_1 | spider | Which state has the greatest total number of bank customers? | train | hard | SELECT state FROM bank GROUP BY state ORDER BY SUM(no_of_customers) DESC LIMIT 1 |
1,583 | loan_1 | spider | For each account type, find the average account balance of customers with credit score lower than 50. | train | medium | SELECT AVG(acc_bal), acc_type FROM customer WHERE credit_score < 50 GROUP BY acc_type |
1,584 | loan_1 | spider | What is the average account balance of customers with credit score below 50 for the different account types? | train | medium | SELECT AVG(acc_bal), acc_type FROM customer WHERE credit_score < 50 GROUP BY acc_type |
1,585 | loan_1 | spider | For each state, find the total account balance of customers whose credit score is above 100. | train | medium | SELECT SUM(acc_bal), state FROM customer WHERE credit_score > 100 GROUP BY state |
1,586 | loan_1 | spider | What is the total account balance for customers with a credit score of above 100 for the different states? | train | medium | SELECT SUM(acc_bal), state FROM customer WHERE credit_score > 100 GROUP BY state |
1,587 | loan_1 | spider | Find the total amount of loans offered by each bank branch. | train | hard | SELECT SUM(amount), t1.bname FROM bank AS t1 JOIN loan AS t2 ON t1.branch_id = t2.branch_id GROUP BY t1.bname |
1,588 | loan_1 | spider | What are the names of the different bank branches, and what are their total loan amounts? | train | hard | SELECT SUM(amount), t1.bname FROM bank AS t1 JOIN loan AS t2 ON t1.branch_id = t2.branch_id GROUP BY t1.bname |
1,589 | loan_1 | spider | Find the name of customers who have more than one loan. | train | hard | SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id GROUP BY t1.cust_name HAVING COUNT(*) > 1 |
1,590 | loan_1 | spider | What are the names of customers who have taken out more than one loan? | train | hard | SELECT t1.cust_name FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id GROUP BY t1.cust_name HAVING COUNT(*) > 1 |
1,591 | loan_1 | spider | Find the name and account balance of the customers who have loans with a total amount of more than 5000. | train | hard | SELECT t1.cust_name, t1.acc_type FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id GROUP BY t1.cust_name HAVING SUM(t2.amount) > 5000 |
1,592 | loan_1 | spider | What are the names and account balances for customers who have taken a total amount of more than 5000 in loans? | train | hard | SELECT t1.cust_name, t1.acc_type FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id GROUP BY t1.cust_name HAVING SUM(t2.amount) > 5000 |
1,593 | loan_1 | spider | Find the name of bank branch that provided the greatest total amount of loans. | train | hard | SELECT t1.bname FROM bank AS t1 JOIN loan AS t2 ON t1.branch_id = t2.branch_id GROUP BY t1.bname ORDER BY SUM(t2.amount) DESC LIMIT 1 |
1,594 | loan_1 | spider | What is the name of the bank branch that has lent the greatest amount? | train | hard | SELECT t1.bname FROM bank AS t1 JOIN loan AS t2 ON t1.branch_id = t2.branch_id GROUP BY t1.bname ORDER BY SUM(t2.amount) DESC LIMIT 1 |
1,595 | loan_1 | spider | Find the name of bank branch that provided the greatest total amount of loans to customers with credit score is less than 100. | train | hard | SELECT t2.bname FROM loan AS t1 JOIN bank AS t2 ON t1.branch_id = t2.branch_id JOIN customer AS t3 ON t1.cust_id = t3.cust_id WHERE t3.credit_score < 100 GROUP BY t2.bname ORDER BY SUM(t1.amount) DESC LIMIT 1 |
1,596 | loan_1 | spider | What is the name of the bank branch that has lended the largest total amount in loans, specifically to customers with credit scores below 100? | train | hard | SELECT t2.bname FROM loan AS t1 JOIN bank AS t2 ON t1.branch_id = t2.branch_id JOIN customer AS t3 ON t1.cust_id = t3.cust_id WHERE t3.credit_score < 100 GROUP BY t2.bname ORDER BY SUM(t1.amount) DESC LIMIT 1 |
1,597 | loan_1 | spider | Find the name of bank branches that provided some loans. | train | hard | SELECT DISTINCT t1.bname FROM bank AS t1 JOIN loan AS t2 ON t1.branch_id = t2.branch_id |
1,598 | loan_1 | spider | What are the names of the different banks that have provided loans? | train | hard | SELECT DISTINCT t1.bname FROM bank AS t1 JOIN loan AS t2 ON t1.branch_id = t2.branch_id |
1,599 | loan_1 | spider | Find the name and credit score of the customers who have some loans. | train | hard | SELECT DISTINCT t1.cust_name, t1.credit_score FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id |
1,600 | loan_1 | spider | What are the different names and credit scores of customers who have taken a loan? | train | hard | SELECT DISTINCT t1.cust_name, t1.credit_score FROM customer AS t1 JOIN loan AS t2 ON t1.cust_id = t2.cust_id |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.