Thursday 17 July 2014

Customer contacts and their phone, email, URL

/* Formatted on 7/17/2014 12:01:39 PM (QP5 v5.115.810.9015) */
SELECT account_number "Account Number",
       obj.party_name "Customer Name",
       sub.party_name "Contact Name",
       hcp.contact_point_type || ': '
       || DECODE (hcp.contact_point_type,
             'EMAIL', hcp.email_address,
             'PHONE', hcp.phone_area_code || ' ' || hcp.phone_number,
             'WEB', hcp.url,
             'Unknow contact Point Type ' || hcp.contact_point_type)
          "How to Contact"
FROM apps.hz_cust_accounts hca,
     apps.hz_parties obj,
     apps.hz_relationships rel,
     apps.hz_contact_points hcp,
     apps.hz_parties sub
WHERE     hca.party_id = rel.object_id
      AND hca.party_id = obj.party_id
      AND rel.subject_id = sub.party_id
      AND rel.relationship_type = 'CONTACT'
      AND rel.directional_flag = 'F'
      AND rel.party_id = hcp.owner_table_id
      AND hcp.owner_table_name = 'HZ_PARTIES';

No comments:

Post a Comment