human
Schema:
accounts (custid, name)
savings (custid, balance)
checking (custid, balance)
Please answer with SQL.
assistant
Sure, I understand.
human
Can you show me the names and total checking and savings account balances?
assistant
SELECT T1.name , T2.balance + T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid;
human
I want to know the average savings balance of all accounts.
assistant
SELECT AVG ( balance ) FROM savings;
human
Hmm, can you list the names of customers whose savings account balances are higher than the average savings balance?
assistant
SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance > ( SELECT AVG ( balance ) FROM savings ) ;