target-benchmark/spider-queries huggingface dataset:
Database: sakila_1 (tables: film_actor, actor)
Question: What are the full names of actors who had roles in more than 30 films?
SQL: SELECT T2.first_name ,  T2.last_name FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id  =  T2.actor_id GROUP BY T2.actor_id HAVING count(*)  >  30
Database: sakila_1 (tables: inventory)
Question: Which store owns most items?
SQL: SELECT store_id FROM inventory GROUP BY store_id ORDER BY count(*) DESC LIMIT 1
Database: sakila_1 (tables: inventory)
Question: What is the id of the store that has the most items in inventory?
SQL: SELECT store_id FROM inventory GROUP BY store_id ORDER BY count(*) DESC LIMIT 1
Database: sakila_1 (tables: payment)
Question: What is the total amount of all payments?
SQL: SELECT sum(amount) FROM payment
Database: sakila_1 (tables: payment)
Question: Return the sum of all payment amounts.
SQL: SELECT sum(amount) FROM payment
Database: sakila_1 (tables: payment, customer)
Question: Which customer, who has made at least one payment, has spent the least money? List his or her first name, last name, and the id.
SQL: SELECT T1.first_name ,  T1.last_name ,  T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY sum(amount) ASC LIMIT 1
Database: sakila_1 (tables: payment, customer)
Question: What is the full name and id of the customer who has the lowest total amount of payment?
SQL: SELECT T1.first_name ,  T1.last_name ,  T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY sum(amount) ASC LIMIT 1
Database: sakila_1 (tables: category, film_category, film)
Question: What is the genre name of the film HUNGER ROOF?
SQL: SELECT T1.name FROM category AS T1 JOIN film_category AS T2 ON T1.category_id  =  T2.category_id JOIN film AS T3 ON T2.film_id  =  T3.film_id WHERE T3.title  =  'HUNGER ROOF'
Database: sakila_1 (tables: category, film_category, film)
Question: Return the name of the category to which the film 'HUNGER ROOF' belongs.
SQL: SELECT T1.name FROM category AS T1 JOIN film_category AS T2 ON T1.category_id  =  T2.category_id JOIN film AS T3 ON T2.film_id  =  T3.film_id WHERE T3.title  =  'HUNGER ROOF'
Database: sakila_1 (tables: category, film_category)
Question: How many films are there in each category? List the genre name, genre id and the count.
SQL: SELECT T2.name ,  T1.category_id ,  count(*) FROM film_category AS T1 JOIN category AS T2 ON T1.category_id  =  T2.category_id GROUP BY T1.category_id
Database: sakila_1 (tables: category, film_category)
Question: What are the names and ids of the different categories, and how many films are in each?
SQL: SELECT T2.name ,  T1.category_id ,  count(*) FROM film_category AS T1 JOIN category AS T2 ON T1.category_id  =  T2.category_id GROUP BY T1.category_id
Database: sakila_1 (tables: inventory, film)
Question: Which film has the most copies in the inventory? List both title and id.
SQL: SELECT T1.title ,  T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id  =  T2.film_id GROUP BY T1.film_id ORDER BY count(*) DESC LIMIT 1
Database: sakila_1 (tables: inventory, film)
Question: What is the title and id of the film that has the greatest number of copies in inventory?
SQL: SELECT T1.title ,  T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id  =  T2.film_id GROUP BY T1.film_id ORDER BY count(*) DESC LIMIT 1
Database: sakila_1 (tables: rental, inventory, film)
Question: What is the film title and inventory id of the item in the inventory which was rented most frequently?
SQL: SELECT T1.title ,  T2.inventory_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id  =  T2.film_id JOIN rental AS T3 ON T2.inventory_id  =  T3.inventory_id GROUP BY T2.inventory_id ORDER BY count(*) DESC LIMIT 1
Database: sakila_1 (tables: rental, inventory, film)
Question: Return the title and inventory id of the film that is rented most often.
SQL: SELECT T1.title ,  T2.inventory_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id  =  T2.film_id JOIN rental AS T3 ON T2.inventory_id  =  T3.inventory_id GROUP BY T2.inventory_id ORDER BY count(*) DESC LIMIT 1
Database: sakila_1 (tables: film)
Question: How many languages are in these films?
SQL: SELECT count(DISTINCT language_id) FROM film
Database: sakila_1 (tables: film)
Question: Count the number of different languages in these films.
SQL: SELECT count(DISTINCT language_id) FROM film
Database: sakila_1 (tables: film)
Question: What are all the movies rated as R? List the titles.
SQL: SELECT title FROM film WHERE rating  =  'R'
Database: sakila_1 (tables: film)
Question: Return the titles of any movies with an R rating.
SQL: SELECT title FROM film WHERE rating  =  'R'
Database: sakila_1 (tables: address, store)
Question: Where is store 1 located?
SQL: SELECT T2.address FROM store AS T1 JOIN address AS T2 ON T1.address_id  =  T2.address_id WHERE store_id  =  1
Database: sakila_1 (tables: address, store)
Question: Return the address of store 1.
SQL: SELECT T2.address FROM store AS T1 JOIN address AS T2 ON T1.address_id  =  T2.address_id WHERE store_id  =  1
Database: sakila_1 (tables: payment, staff)
Question: Which staff handled least number of payments? List the full name and the id.
SQL: SELECT T1.first_name ,  T1.last_name ,  T1.staff_id FROM staff AS T1 JOIN payment AS T2 ON T1.staff_id  =  T2.staff_id GROUP BY T1.staff_id ORDER BY count(*) ASC LIMIT 1
Database: sakila_1 (tables: payment, staff)
Question: Give the full name and staff id of the staff who has handled the fewest payments.
SQL: SELECT T1.first_name ,  T1.last_name ,  T1.staff_id FROM staff AS T1 JOIN payment AS T2 ON T1.staff_id  =  T2.staff_id GROUP BY T1.staff_id ORDER BY count(*) ASC LIMIT 1
Database: sakila_1 (tables: language, film)
Question: Which language does the film AIRPORT POLLOCK use? List the language name.
SQL: SELECT T2.name FROM film AS T1 JOIN LANGUAGE AS T2 ON T1.language_id  =  T2.language_id WHERE T1.title  =  'AIRPORT POLLOCK'
Database: sakila_1 (tables: language, film)
Question: What is the name of the language that the film 'AIRPORT POLLOCK' is in?
SQL: SELECT T2.name FROM film AS T1 JOIN LANGUAGE AS T2 ON T1.language_id  =  T2.language_id WHERE T1.title  =  'AIRPORT POLLOCK'
Database: sakila_1 (tables: store)
Question: How many stores are there?
SQL: SELECT count(*) FROM store
Database: sakila_1 (tables: store)
Question: Count the number of stores.
SQL: SELECT count(*) FROM store
Database: sakila_1 (tables: film)
Question: How many kinds of different ratings are listed?
SQL: SELECT count(DISTINCT rating) FROM film
Database: sakila_1 (tables: film)
Question: Count the number of different film ratings.
SQL: SELECT count(DISTINCT rating) FROM film
Database: sakila_1 (tables: film)
Question: Which movies have 'Deleted Scenes' as a substring in the special feature?
SQL: SELECT title FROM film WHERE special_features LIKE '%Deleted Scenes%'
Database: sakila_1 (tables: film)
Question: Return the titles of films that include 'Deleted Scenes' in their special feature section.
SQL: SELECT title FROM film WHERE special_features LIKE '%Deleted Scenes%'
Database: sakila_1 (tables: inventory)
Question: How many items in inventory does store 1 have?
SQL: SELECT count(*) FROM inventory WHERE store_id  =  1
Database: sakila_1 (tables: inventory)
Question: Count the number of items store 1 has in stock.
SQL: SELECT count(*) FROM inventory WHERE store_id  =  1
Database: sakila_1 (tables: payment)
Question: When did the first payment happen?
SQL: SELECT payment_date FROM payment ORDER BY payment_date ASC LIMIT 1
Database: sakila_1 (tables: payment)
Question: What was the date of the earliest payment?
SQL: SELECT payment_date FROM payment ORDER BY payment_date ASC LIMIT 1
Database: sakila_1 (tables: address, customer)
Question: Where does the customer with the first name Linda live? And what is her email?
SQL: SELECT T2.address ,  T1.email FROM customer AS T1 JOIN address AS T2 ON T2.address_id  =  T1.address_id WHERE T1.first_name  =  'LINDA'
Database: sakila_1 (tables: address, customer)
Question: Return the address and email of the customer with the first name Linda.
SQL: SELECT T2.address ,  T1.email FROM customer AS T1 JOIN address AS T2 ON T2.address_id  =  T1.address_id WHERE T1.first_name  =  'LINDA'
Database: sakila_1 (tables: film)
Question: Find all the films longer than 100 minutes, or rated PG, except those who cost more than 200 for replacement. List the titles.
SQL: SELECT title FROM film WHERE LENGTH  >  100 OR rating  =  'PG' EXCEPT SELECT title FROM film WHERE replacement_cost  >  200
Database: sakila_1 (tables: film)
Question: What are the titles of films that are either longer than 100 minutes or rated PG other than those that cost more than 200 to replace?
SQL: SELECT title FROM film WHERE LENGTH  >  100 OR rating  =  'PG' EXCEPT SELECT title FROM film WHERE replacement_cost  >  200
Database: sakila_1 (tables: rental, customer)
Question: What is the first name and the last name of the customer who made the earliest rental?
SQL: SELECT T1.first_name ,  T1.last_name FROM customer AS T1 JOIN rental AS T2 ON T1.customer_id  =  T2.customer_id ORDER BY T2.rental_date ASC LIMIT 1
Database: sakila_1 (tables: rental, customer)
Question: Return the full name of the customer who made the first rental.
SQL: SELECT T1.first_name ,  T1.last_name FROM customer AS T1 JOIN rental AS T2 ON T1.customer_id  =  T2.customer_id ORDER BY T2.rental_date ASC LIMIT 1
Database: sakila_1 (tables: rental, customer, staff)
Question: What is the full name of the staff member who has rented a film to a customer with the first name April and the last name Burns?
SQL: SELECT DISTINCT T1.first_name ,  T1.last_name FROM staff AS T1 JOIN rental AS T2 ON T1.staff_id  =  T2.staff_id JOIN customer AS T3 ON T2.customer_id  =  T3.customer_id WHERE T3.first_name  =  'APRIL' AND T3.last_name  =  'BURNS'
Database: sakila_1 (tables: rental, customer, staff)
Question: Return the full name of the staff who provided a customer with the first name April and the last name Burns with a film rental.
SQL: SELECT DISTINCT T1.first_name ,  T1.last_name FROM staff AS T1 JOIN rental AS T2 ON T1.staff_id  =  T2.staff_id JOIN customer AS T3 ON T2.customer_id  =  T3.customer_id WHERE T3.first_name  =  'APRIL' AND T3.last_name  =  'BURNS'
Database: sakila_1 (tables: customer)
Question: Which store has most the customers?
SQL: SELECT store_id FROM customer GROUP BY store_id ORDER BY count(*) DESC LIMIT 1
Database: sakila_1 (tables: customer)
Question: Return the id of the store with the most customers.
SQL: SELECT store_id FROM customer GROUP BY store_id ORDER BY count(*) DESC LIMIT 1
Database: sakila_1 (tables: payment)
Question: What is the largest payment amount?
SQL: SELECT amount FROM payment ORDER BY amount DESC LIMIT 1
Database: sakila_1 (tables: payment)
Question: Return the amount of the largest payment.
SQL: SELECT amount FROM payment ORDER BY amount DESC LIMIT 1
Database: sakila_1 (tables: address, staff)
Question: Where does the staff member with the first name Elsa live?
SQL: SELECT T2.address FROM staff AS T1 JOIN address AS T2 ON T1.address_id  =  T2.address_id WHERE T1.first_name  =  'Elsa'
Database: sakila_1 (tables: address, staff)
Question: Give the address of the staff member who has the first name Elsa.
SQL: SELECT T2.address FROM staff AS T1 JOIN address AS T2 ON T1.address_id  =  T2.address_id WHERE T1.first_name  =  'Elsa'
Database: sakila_1 (tables: rental, customer)
Question: What are the first names of customers who have not rented any films after '2005-08-23 02:06:01'?
SQL: SELECT first_name FROM customer WHERE customer_id NOT IN( SELECT customer_id FROM rental WHERE rental_date  >  '2005-08-23 02:06:01' )
Database: sakila_1 (tables: rental, customer)
Question: Return the first names of customers who did not rented a film after the date '2005-08-23 02:06:01'.
SQL: SELECT first_name FROM customer WHERE customer_id NOT IN( SELECT customer_id FROM rental WHERE rental_date  >  '2005-08-23 02:06:01' )
Database: loan_1 (tables: bank)
Question: How many bank branches are there?
SQL: SELECT count(*) FROM bank
Database: loan_1 (tables: bank)
Question: Count the number of bank branches.
SQL: SELECT count(*) FROM bank
Database: loan_1 (tables: bank)
Question: How many customers are there?
SQL: SELECT sum(no_of_customers) FROM bank
Database: loan_1 (tables: bank)
Question: What is the total number of customers across banks?
SQL: SELECT sum(no_of_customers) FROM bank
Database: loan_1 (tables: bank)
Question: Find the number of customers in the banks at New York City.
SQL: SELECT sum(no_of_customers) FROM bank WHERE city  =  'New York City'
Database: loan_1 (tables: bank)
Question: What is the total number of customers who use banks in New York City?
SQL: SELECT sum(no_of_customers) FROM bank WHERE city  =  'New York City'
Database: loan_1 (tables: bank)
Question: Find the average number of customers in all banks of Utah state.
SQL: SELECT avg(no_of_customers) FROM bank WHERE state  =  'Utah'
Database: loan_1 (tables: bank)
Question: What is the average number of customers across banks in the state of Utah?
SQL: SELECT avg(no_of_customers) FROM bank WHERE state  =  'Utah'
Database: loan_1 (tables: bank)
Question: Find the average number of customers cross all banks.
SQL: SELECT avg(no_of_customers) FROM bank
Database: loan_1 (tables: bank)
Question: What is the average number of bank customers?
SQL: SELECT avg(no_of_customers) FROM bank
Database: loan_1 (tables: bank)
Question: Find the city and state of the bank branch named morningside.
SQL: SELECT city ,  state FROM bank WHERE bname  =  'morningside'
Database: loan_1 (tables: bank)
Question: What city and state is the bank with the name morningside in?
SQL: SELECT city ,  state FROM bank WHERE bname  =  'morningside'
Database: loan_1 (tables: bank)
Question: Find the branch names of banks in the New York state.
SQL: SELECT bname FROM bank WHERE state  =  'New York'
Database: loan_1 (tables: bank)
Question: What are the names of banks in the state of New York?
SQL: SELECT bname FROM bank WHERE state  =  'New York'
Database: loan_1 (tables: customer)
Question: List the name of all customers sorted by their account balance in ascending order.
SQL: SELECT cust_name FROM customer ORDER BY acc_bal
Database: loan_1 (tables: customer)
Question: What are the names of all customers, ordered by account balance?
SQL: SELECT cust_name FROM customer ORDER BY acc_bal
Database: loan_1 (tables: loan, customer)
Question: List the name of all different customers who have some loan sorted by their total loan amount.
SQL: 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)
Database: loan_1 (tables: loan, customer)
Question: What are the names of the different customers who have taken out a loan, ordered by the total amount that they have taken?
SQL: 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)
Database: loan_1 (tables: customer)
Question: Find the state, account type, and credit score of the customer whose number of loan is 0.
SQL: SELECT state ,  acc_type ,  credit_score FROM customer WHERE no_of_loans  =  0
Database: loan_1 (tables: customer)
Question: What are the states, account types, and credit scores for customers who have 0 loans?
SQL: SELECT state ,  acc_type ,  credit_score FROM customer WHERE no_of_loans  =  0
Database: loan_1 (tables: bank)
Question: Find the number of different cities which banks are located at.
SQL: SELECT count(DISTINCT city) FROM bank
Database: loan_1 (tables: bank)
Question: In how many different cities are banks located?
SQL: SELECT count(DISTINCT city) FROM bank
Database: loan_1 (tables: bank)
Question: Find the number of different states which banks are located at.
SQL: SELECT count(DISTINCT state) FROM bank
Database: loan_1 (tables: bank)
Question: In how many different states are banks located?
SQL: SELECT count(DISTINCT state) FROM bank
Database: loan_1 (tables: customer)
Question: How many distinct types of accounts are there?
SQL: SELECT count(DISTINCT acc_type) FROM customer
Database: loan_1 (tables: customer)
Question: Count the number of different account types.
SQL: SELECT count(DISTINCT acc_type) FROM customer
Database: loan_1 (tables: customer)
Question: Find the name and account balance of the customer whose name includes the letter ‘a’.
SQL: SELECT cust_name ,  acc_bal FROM customer WHERE cust_name LIKE '%a%'
Database: loan_1 (tables: customer)
Question: What are the names and account balances of customers with the letter a in their names?
SQL: SELECT cust_name ,  acc_bal FROM customer WHERE cust_name LIKE '%a%'
Database: loan_1 (tables: customer)
Question: Find the total account balance of each customer from Utah or Texas.
SQL: SELECT sum(acc_bal) FROM customer WHERE state  =  'Utah' OR state  =  'Texas'
Database: loan_1 (tables: customer)
Question: What are the total account balances for each customer from Utah or Texas?
SQL: SELECT sum(acc_bal) FROM customer WHERE state  =  'Utah' OR state  =  'Texas'
Database: loan_1 (tables: customer)
Question: Find the name of customers who have both saving and checking account types.
SQL: SELECT cust_name FROM customer WHERE acc_type  =  'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type  =  'checking'
Database: loan_1 (tables: customer)
Question: What are the names of customers who have both savings and checking accounts?
SQL: SELECT cust_name FROM customer WHERE acc_type  =  'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type  =  'checking'
Database: loan_1 (tables: customer)
Question: Find the name of customers who do not have an saving account.
SQL: SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type  =  'saving'
Database: loan_1 (tables: customer)
Question: What are the names of customers who do not have saving accounts?
SQL: SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type  =  'saving'
Database: loan_1 (tables: loan, customer)
Question: Find the name of customers who do not have a loan with a type of Mortgages.
SQL: 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'
Database: loan_1 (tables: loan, customer)
Question: What are the names of customers who have not taken a Mortage loan?
SQL: 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'
Database: loan_1 (tables: loan, customer)
Question: Find the name of customers who have loans of both Mortgages and Auto.
SQL: 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'
Database: loan_1 (tables: loan, customer)
Question: What are the names of customers who have taken both Mortgage and Auto loans?
SQL: 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'
Database: loan_1 (tables: customer)
Question: Find the name of customers whose credit score is below the average credit scores of all customers.
SQL: SELECT cust_name FROM customer WHERE credit_score  <  (SELECT avg(credit_score) FROM customer)
Database: loan_1 (tables: customer)
Question: What are the names of customers with credit score less than the average credit score across customers?
SQL: SELECT cust_name FROM customer WHERE credit_score  <  (SELECT avg(credit_score) FROM customer)
Database: loan_1 (tables: bank)
Question: Find the branch name of the bank that has the most number of customers.
SQL: SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1
Database: loan_1 (tables: bank)
Question: What is the name of the bank branch with the greatest number of customers?
SQL: SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1
Database: loan_1 (tables: customer)
Question: Find the name of customer who has the lowest credit score.
SQL: SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1
Database: loan_1 (tables: customer)
Question: What is the name of the customer with the worst credit score?
SQL: SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1
Database: loan_1 (tables: customer)
Question: Find the name, account type, and account balance of the customer who has the highest credit score.
SQL: SELECT cust_name ,  acc_type ,  acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1
Database: loan_1 (tables: customer)
Question: What is the name, account type, and account balance corresponding to the customer with the highest credit score?
SQL: SELECT cust_name ,  acc_type ,  acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1
Database: loan_1 (tables: loan, customer)
Question: Find the name of customer who has the highest amount of loans.
SQL: 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
Database: loan_1 (tables: loan, customer)
Question: What is the name of the customer who has greatest total loan amount?
SQL: 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
Database: loan_1 (tables: bank)
Question: Find the state which has the most number of customers.
SQL: SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1
Database: loan_1 (tables: bank)
Question: Which state has the greatest total number of bank customers?
SQL: SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1
Database: loan_1 (tables: customer)
Question: For each account type, find the average account balance of customers with credit score lower than 50.
SQL: SELECT avg(acc_bal) ,  acc_type FROM customer WHERE credit_score  <  50 GROUP BY acc_type
Database: loan_1 (tables: customer)
Question: What is the average account balance of customers with credit score below 50 for the different account types?
SQL: SELECT avg(acc_bal) ,  acc_type FROM customer WHERE credit_score  <  50 GROUP BY acc_type
Database: loan_1 (tables: customer)
Question: For each state, find the total account balance of customers whose credit score is above 100.
SQL: SELECT sum(acc_bal) ,  state FROM customer WHERE credit_score  >  100 GROUP BY state
Database: loan_1 (tables: customer)
Question: What is the total account balance for customers with a credit score of above 100 for the different states?
SQL: SELECT sum(acc_bal) ,  state FROM customer WHERE credit_score  >  100 GROUP BY state
Database: loan_1 (tables: bank, loan)
Question: Find the total amount of loans offered by each bank branch.
SQL: SELECT sum(amount) ,  T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id GROUP BY T1.bname
Database: loan_1 (tables: bank, loan)
Question: What are the names of the different bank branches, and what are their total loan amounts?
SQL: SELECT sum(amount) ,  T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id GROUP BY T1.bname
Database: loan_1 (tables: loan, customer)
Question: Find the name of customers who have more than one loan.
SQL: 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
Database: loan_1 (tables: loan, customer)
Question: What are the names of customers who have taken out more than one loan?
SQL: 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
Database: loan_1 (tables: loan, customer)
Question: Find the name and account balance of the customers who have loans with a total amount of more than 5000.
SQL: 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