#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    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.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2008
    Posts
    1,928
    Rep Power
    378
    The idea of homework is that YOU do it!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0
    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.

    Code:
    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)
    I have no idea on how to select branches with the same state as the customer

IMN logo majestic logo threadwatch logo seochat tools logo