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
hello. Can you tell me the number of states in which there are customers?
assistant
SELECT COUNT( state ) FROM bank WHERE no_of_customers > 0;
human
and what states are they, please? | Do you mean the states of all the branches? | what are the four states in which there are customers ?
assistant
SELECT state FROM bank WHERE no_of_customers > 0;
human
and which of those states has the most number of customers?
assistant
SELECT state FROM bank GROUP BY state ORDER BY SUM( no_of_customers ) DESC LIMIT 1 ;