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 number of customers in the banks at New York City.
assistant
SELECT sum(no_of_customers) FROM bank WHERE city = 'New York City'
human
Find the average credit score of the customers who have some loan.
assistant
SELECT avg(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan)
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 total account balance of each customer from Utah or Texas.
assistant
SELECT sum(acc_bal) FROM customer WHERE state = 'Utah' OR state = 'Texas'
human
Find the average number of customers cross all banks.
assistant
SELECT avg(no_of_customers) FROM bank
human
Find the average number of customers in all banks of Utah state.
assistant
SELECT avg ( no_of_customers ) FROM bank WHERE state = "Utah" ;