October 28th, 2012, 11:33 PM
Need help with this query
My database structure is
http:// imgur.com/ LkqBI (can't post links-Remove spaces)
I need to Find customers who own an account with a balance larger than that average balance of all accounts held in branches located in the same state as the customer. Display information as described in query above.
October 29th, 2012, 05:35 AM
The idea of homework is that YOU do it!
October 29th, 2012, 12:33 PM
This is a practice problem,but you are right,you have no reason to believe me.Can you atleast point me in the right direction regarding the second part of the query.Here is what i did for the first part.
I have no idea on how to select branches with the same state as the customer
SELECT fname,lname,B.id FROM
customers A INNER JOIN depositors D on A.id=D.cid INNER JOIN accounts C on D.account_number=C.account_number INNER JOIN branches B ON C.branch_id=B.id
WHERE C.balance>(SELECT AVG(balance) FROM accounts)