human
Schema:
accounts (custid, name)
savings (custid, balance)
checking (custid, balance)
Please answer with SQL.
assistant
Sure, I understand.
human
What is the maximum savings balance?
assistant
SELECT MAX( balance ) FROM savings;
human
What is the average?
assistant
SELECT AVG ( balance ) FROM savings;
human
Who are names of the people that are above this average?
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 );
human
How many of them are there?
assistant
SELECT COUNT( * ) FROM savings WHERE balance > ( SELECT AVG ( balance ) FROM savings ) ;