Nov 17, 2010

What is Query for getting customers having multiple accounts?

 What is Query for getting customers having multiple accounts?
 and How to get customers having multiple accounts?

SELECT hca.account_number,rc.customer_name, hp.party_type,hp.party_name
 FROM hz_parties hp, hz_Cust_Accounts hca,ar.ra_customers rc
WHERE hp.party_id = hca.party_id
and rc.customer_id=hca.cust_Account_id
  AND hca.cust_account_id IN (
         SELECT   customer_id
             FROM ap_bank_account_uses_all bauses,
                  ap_bank_accounts_all bacct
            WHERE bauses.external_bank_account_id = bacct.bank_account_id
              AND primary_flag = 'Y'
         GROUP BY customer_id)
          HAVING COUNT (DISTINCT (external_bank_account_id)) > 1)
          
          
         

No comments:

OraApps Search

Custom Search

Search This Blog