human
Schema:
bank (branch_ID, bname, no_of_customers, city, state)
customer (cust_ID, cust_name, acc_type, acc_bal, no_of_loans, credit_score, branch_ID, state)
loan (loan_ID, loan_type, cust_ID, branch_ID, amount)
Please answer with SQL.
assistant
Sure, I understand.
human
Find the branch name of the bank that has the most number of customers.
assistant
SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1
human
Find the name of customers who do not have an saving account.
assistant
SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'
human
Find the name, account type, and account balance of the customer who has the highest credit score.
assistant
SELECT cust_name , acc_type , acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1
human
Find the name and account balance of the customer whose name includes the letter a .
assistant
SELECT cust_name , acc_bal FROM customer WHERE cust_name LIKE '%a%'
human
List the name of all different customers who have some loan sorted by their total loan amount.
assistant
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)
human
What are the names of all customers, ordered by account balance?
assistant
SELECT cust_name FROM customer ORDER BY acc_bal ;