Can you tell me the average checking balance of all checking accounts?
select avg ( balance ) from checking
Hmm, I also want to know the average savings balance of all savings accounts.
select avg ( balance ) from savings
Can you list the names of accounts whose checking balance is above the average checking balance, but savings balance is below the average savings balance?
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 )