Database: small_bank_1

Question: Find the total saving balance for each account name.
SQL: SELECT sum(T2.balance) ,  T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid GROUP BY T1.name

Question: Find the name of accounts whose checking balance is below the average checking balance.
SQL: SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  <  (SELECT avg(balance) FROM checking)

Question: Find the saving balance of the account with the highest checking balance.
SQL: SELECT T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid JOIN savings AS T3 ON T1.custid  =  T3.custid ORDER BY T2.balance DESC LIMIT 1

Question: Find the total checking and saving balance of all accounts sorted by the total balance in ascending order.
SQL: SELECT T1.balance + T2.balance FROM checking AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid ORDER BY T1.balance + T2.balance

Question: Find the name and checking balance of the account with the lowest saving balance.
SQL: SELECT T2.balance,  T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid JOIN savings AS T3 ON T1.custid  =  T3.custid ORDER BY T3.balance LIMIT 1

Question: Find the name, checking balance and saving balance of all accounts in the bank.
SQL: SELECT T2.balance ,  T3.balance ,  T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid JOIN savings AS T3 ON T1.custid  =  T3.custid

Question: Find the name, checking balance and savings balance of all accounts in the bank sorted by their total checking and savings balance in descending order.
SQL: SELECT T2.balance ,  T3.balance ,  T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid JOIN savings AS T3 ON T1.custid  =  T3.custid ORDER BY T2.balance + T3.balance DESC

Question: Find the name of accounts whose checking balance is higher than corresponding saving balance.
SQL: SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid JOIN savings AS T3 ON T1.custid  =  T3.custid WHERE T2.balance  >  T3.balance

Question: Find the name and total checking and savings balance of the accounts whose savings balance is lower than corresponding checking balance.
SQL: SELECT T1.name,  T3.balance + T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid JOIN savings AS T3 ON T1.custid  =  T3.custid WHERE T3.balance  <  T2.balance