How many accounts have higher savings balances than their checking balances?
select count(*) 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
How about higher checking balances than their saving balances?
select count(*) 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
Show me the checking balances and saving balances for each of these 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 t2.balance > t3.balance
Actually, just show me the corresponding names.
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