human
Schema:
accounts (custid, name)
savings (custid, balance)
checking (custid, balance)
Please answer with SQL.
assistant
Sure, I understand.
human
Find the name of account that has the lowest total checking and saving balance.
assistant
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;
human
Ok!. Can you please give me the names of the accounts where the checking balance is more than 3000
assistant
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 > 3000;
human
Give me the names of the accounts where the savings balance is more than 20000
assistant
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 T3.balance > 20000;
human
What is the highest balance in the savings account?
assistant
SELECT balance FROM SAVINGS ORDER by balance desc LIMIT 1;
human
Hmmm. Please tell me what is the lowest balance in the savings account.
assistant
SELECT MIN( balance ) FROM SAVINGS;
human
Can you also give me the lowest and the highest balance for checking account.
assistant
SELECT MAX( balance ) , MIN( balance ) FROM CHECKING ;