Friday, 4 July 2014

Query to check Duplicates in iby_external_payees_all table

/* Formatted on 7/4/2014 10:42:56 AM (QP5 v5.115.810.9015) */
SELECT a.ext_payee_id,
       a.payee_party_id,
       a.payment_function,
       a.exclusive_payment_flag,
       a.party_site_id,
       a.supplier_site_id,
       a.org_id,
       a.org_type,
       a.default_payment_method_code,
       a.ece_tp_location_code,
       a.bank_charge_bearer,
       a.bank_instruction1_code,
       a.bank_instruction2_code,
       a.bank_instruction_details,
       a.payment_reason_code,
       a.payment_reason_comments,
       a.inactive_date,
       a.payment_text_message1,
       a.payment_text_message2,
       a.payment_text_message3,
       a.delivery_channel_code,
       a.payment_format_code,
       a.settlement_priority,
       a.remit_advice_delivery_method,
       a.remit_advice_email,
       a.remit_advice_fax
FROM iby_external_payees_all a
WHERE EXISTS
         (SELECT 'duplicates'
          FROM iby_external_payees_all b
          WHERE     a.payee_party_id = b.payee_party_id
                AND a.payment_function = b.payment_function
                AND NVL (a.party_site_id, '0') = NVL (b.party_site_id, '0')
                AND NVL (a.supplier_site_id, '0') =
                      NVL (b.supplier_site_id, '0')
                AND NVL (a.org_id, '0') = NVL (b.org_id, '0')
                AND NVL (a.org_type, '0') = NVL (b.org_type, '0')
                AND a.ext_payee_id <> b.ext_payee_id)
ORDER BY a.payee_party_id, a.last_update_date DESC;

No comments:

Post a Comment