Friday, 3 July 2015

Query to Find Suppliers With Banking Details

SELECT ap.segment1 Vendor_number,       
              ap.vendor_name,
            aps.vendor_site_code,
            aps.ADDRESS_LINE1,
            aps.ADDRESS_LINE2,
            aps.ADDRESS_LINE3,
            aps.CITY ,
            aps.STATE ,
            aps.country,
            (select tax_reference
               from hz_parties
              where party_id = ap.party_id) Tax_Registration_No,
            ieb.bank_name,
            ieb.Bank_Number,
            ieba.bank_account_name,
            ieba.bank_account_num,
            ieba.iban iban_Number,
            iebb.bank_branch_name,
            iebb.eft_swift_code,
            iebb.branch_number,
            iebb.bank_branch_type,
            ieb.country
  FROM ap_suppliers ap,
           ap_supplier_sites_all aps,
           iby_ext_bank_accounts ieba,
           iby_account_owners iao,
           iby_ext_banks_v ieb,
           iby_ext_bank_branches_v iebb
 WHERE 1=1
   AND ap.vendor_id = aps.vendor_id
   AND iao.account_owner_party_id = ap.party_id
   AND ieba.ext_bank_account_id = iao.ext_bank_account_id
   AND ieb.bank_party_id = iebb.bank_party_id
   AND ieba.branch_id = iebb.branch_party_id
   AND ieba.bank_id = ieb.bank_party_id
   AND iao.primary_flag = 'Y'

No comments:

Post a Comment