CREATE TABLE ACCOUNTS (
    custid NUMBER PRIMARY KEY,
    name TEXT
);
CREATE TABLE SAVINGS (
    custid NUMBER PRIMARY KEY,
    balance NUMBER,
    FOREIGN KEY ("custid") REFERENCES ACCOUNTS("custid")
);
CREATE TABLE CHECKING (
    custid NUMBER PRIMARY KEY,
    balance NUMBER,
    FOREIGN KEY ("custid") REFERENCES ACCOUNTS("custid")
);

Question: What are the names of customers with checking balances lower than 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: What is the savings balance of the account belonging to the customer 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: What is the sum of checking and savings balances for all customers, ordered by the total balance?
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: What is the name and checking balance of the account which has the lowest savings 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: What are the names, checking balances, and savings balances for all customers?
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: What are the names, checking balances, and savings balances of customers, ordered by the total of checking and savings balances descending?
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: What are the names of customers with a higher checking balance than savings 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

Question: What are the names of customers who have a savings balance lower than their checking balance, and what is the total of their checking and savings balances?
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

Question: Find the name and savings balance of the top 3 accounts with the highest saving balance sorted by savings balance in descending order.
SQL: SELECT T1.name ,  T2.balance FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid ORDER BY T2.balance DESC LIMIT 3

Question: What are names and savings balances of the three accounts with the highest savings balances?
SQL: SELECT T1.name ,  T2.balance FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid ORDER BY T2.balance DESC LIMIT 3