human
Schema:
accounts (custid, name)
savings (custid, balance)
checking (custid, balance)
Please answer with SQL.
assistant
Sure, I understand.
human
What is the checking balance of the account whose owner s name contains the substring ee ?
assistant
SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name LIKE '%ee%'
human
What is the total checking balance in all accounts?
assistant
SELECT sum(balance) FROM checking
human
How many accounts have a savings balance above the average savings balance?
assistant
SELECT count(*) FROM savings WHERE balance > (SELECT avg(balance) FROM savings)
human
Find the total saving balance for each account name.
assistant
SELECT sum(T2.balance) , T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid GROUP BY T1.name
human
Find the checking balance and saving balance in the Brown s account.
assistant
SELECT 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 WHERE T1.name = 'Brown'
human
What is the total balance of savings accounts not belonging to someone with the name Brown?
assistant
SELECT SUM( T2.balance ) FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T1.name != "Brown" ;