Database: small_bank_1
Schema:
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

Question: Find the total savings balance of all accounts except the account with name ‘Brown’.
SQL: SELECT sum(T2.balance) FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid WHERE T1.name != 'Brown'

Question: What is the total balance of savings accounts not belonging to someone with the name Brown?
SQL: SELECT sum(T2.balance) FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid WHERE T1.name != 'Brown'

Question: How many accounts are there in total?
SQL: SELECT count(*) FROM accounts

Question: Count the number of accounts.
SQL: SELECT count(*) FROM accounts

Question: What is the total checking balance in all accounts?
SQL: SELECT sum(balance) FROM checking

Question: Find the total balance across checking accounts.
SQL: SELECT sum(balance) FROM checking

Question: Find the average checking balance.
SQL: SELECT avg(balance) FROM checking

Question: What is the average balance in checking accounts?
SQL: SELECT avg(balance) FROM checking

Question: How many accounts have a savings balance above the average savings balance?
SQL: SELECT count(*) FROM savings WHERE balance  >  (SELECT avg(balance) FROM savings)

Question: Find the number of accounts with a savings balance that is higher than the average savings balance.
SQL: SELECT count(*) FROM savings WHERE balance  >  (SELECT avg(balance) FROM savings)

Question: Find the name and id of accounts whose checking balance is below the maximum checking balance.
SQL: SELECT T1.custid ,  T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  <  (SELECT max(balance) FROM checking)

Question: What are the customer id and name corresponding to accounts with a checking balance less than the largest checking balance?
SQL: SELECT T1.custid ,  T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  <  (SELECT max(balance) FROM checking)

Question: What is the checking balance of the account whose owner’s name contains the substring ‘ee’?
SQL: SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T1.name LIKE '%ee%'

Question: Find the balance of the checking account belonging to an owner whose name contains 'ee'.
SQL: SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T1.name LIKE '%ee%'

Question: Find the checking balance and saving balance in the Brown’s account.
SQL: 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'

Question: What are the checking and savings balances in accounts belonging to Brown?
SQL: 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'

Question: Find the names of accounts whose checking balance is above the average checking balance, but savings balance is below the average savings 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) INTERSECT SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  <  (SELECT avg(balance) FROM savings)

Question: What are the names of accounts with checking balances greater than the average checking balance and savings balances below the average savings 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) INTERSECT SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  <  (SELECT avg(balance) FROM savings)

Question: Find the checking balance of the accounts whose savings balance is higher than the average savings balance.
SQL: 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))

Question: What are the balances of checking accounts belonging to people with savings balances greater than the average savings balance?
SQL: 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))

Question: List all customers’ names in the alphabetical order.
SQL: SELECT name FROM accounts ORDER BY name

Question: What are the names of all the customers in alphabetical order?
SQL: SELECT name FROM accounts ORDER BY name

Question: Find the name of account that has the lowest total checking and 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 ORDER BY T2.balance + T3.balance LIMIT 1

Question: What is the name corresponding to the accoung with the lowest sum of checking and savings balances?
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 ORDER BY T2.balance + T3.balance LIMIT 1

Question: Find the names and total checking and savings balances of accounts whose savings balance is higher than the average savings balance.
SQL: SELECT T1.name ,  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 T3.balance  >  (SELECT avg(balance) FROM savings)

Question: What are the names and sum of checking and savings balances for accounts with savings balances higher than the average savings balance?
SQL: SELECT T1.name ,  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 T3.balance  >  (SELECT avg(balance) FROM savings)

Question: Find the name and checking balance of the account with the lowest savings balance.
SQL: SELECT T1.name ,  T2.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 T3.balance LIMIT 1

Question: What are the names and balances of checking accounts belonging to the customer with the lowest savings balance?
SQL: SELECT T1.name ,  T2.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 T3.balance LIMIT 1

Question: Find the number of checking accounts for each account name.
SQL: SELECT count(*) ,  T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid GROUP BY T1.name

Question: What are the names of customers with accounts, and how many checking accounts do each of them have?
SQL: SELECT count(*) ,  T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid GROUP BY T1.name

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: What are the names of customers with accounts, and what are the total savings balances for each?
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: 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