human
Schema:
accounts (custid, name)
savings (custid, balance)
checking (custid, balance)
Please answer with SQL.
assistant
Sure, I understand.
human
How many balance of customer id 1? | Do you want the saving balance of the customer with id 1? | Yes
assistant
SELECT balance FROM savings WHERE custid = 1;
human
Find the savings balance of Wang?
assistant
SELECT T2.balance FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T1.name = 'Wang';
human
What are the accountant name of customer id 3?
assistant
SELECT name FROM accounts WHERE custid = 3;
human
Find the checking balance of the accounts whose savings balance is higher than the average savings balance.
assistant
SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name IN ( SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance > ( SELECT AVG ( balance ) FROM savings ) ) ;