Hi, could you please let me know what is the average savings balance of all customers?
select avg ( balance ) from savings
Awesome, thank you. Then could you please show me the ID of the customers who have higher balance than this average?
select custid from savings where balance > ( select avg ( balance ) from savings )
oh that's a bit surprising, maybe this person is elevating the average a lot. Thank you, then could you please show me this customer's balance on both CHECKING and SAVINGS table?
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 t3.balance > ( select avg ( balance ) from savings )
That's great, thank you. Then could you please let me know what is the sum of those two accounts?
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 t3.balance > ( select avg ( balance ) from savings )
Thank you. Then could you please let me know what would be the difference between the balances of the two accounts?
select 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 > ( select avg ( balance ) from savings )