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 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
How many customers are there?
assistant
SELECT sum(no_of_customers) FROM bank
human
For each account type, find the average account balance of customers with credit score lower than 50.
assistant
SELECT avg(acc_bal) , acc_type FROM customer WHERE credit_score < 50 GROUP BY acc_type
human
How many bank branches are there?
assistant
SELECT count(*) FROM bank
human
Find the name of customers who have both saving and checking account types.
assistant
SELECT cust_name FROM customer WHERE acc_type = 'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type = 'checking'
human
How many distinct types of accounts are there?
assistant
SELECT COUNT( DISTINCT acc_type ) FROM customer ;