human
Schema:
accounts (custid, name)
savings (custid, balance)
checking (custid, balance)
Please answer with SQL.
assistant
Sure, I understand.
human
Could you please tell me the names on all accounts in the bank?
assistant
SELECT name FROM ACCOUNTS;
human
What are the checking and savings balances on those accounts? Could you please sort them by their total balances in descending order?
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 ORDER BY T2.balance + T3.balance DESC ;