Thursday 17 July 2014

Available phones/emails/web for an account Detail Query

/* Formatted on 7/17/2014 12:11:32 PM (QP5 v5.115.810.9015) */
SELECT account_number,
       'Party LeveL Communication' communication_level,
       phne.contact_point_purpose,
       phne.contact_point_type,
       DECODE (phne.contact_point_type,
               'PHONE',
               '(' || phne.phone_area_code || ') ' || phne.phone_number,
               'EMAIL',
               phne.email_address,
               'WEB',
               phne.url
       )
          comm_detail,
       phne.primary_flag,
       NULL address
FROM hz_contact_points phne, hz_cust_accounts acct
WHERE     acct.party_id = phne.owner_table_id
      AND phne.owner_table_name = 'HZ_PARTIES'
      AND acct.account_number = '1000'
UNION
SELECT account_number,
       'Party Site LeveL Communication',
       phne.contact_point_purpose,
       phne.contact_point_type,
       DECODE (phne.contact_point_type,
               'PHONE',
               '(' || phne.phone_area_code || ') ' || phne.phone_number,
               'EMAIL',
               phne.email_address,
               'WEB',
               phne.url
       )
          comm_detail,
       phne.primary_flag,
          loc.address1
       || ','
       || loc.address2
       || ','
       || loc.city
       || ','
       || loc.state
       || ','
       || loc.postal_code
          address
FROM hz_contact_points phne,
     hz_cust_acct_sites_all site,
     hz_cust_accounts acct,
     hz_party_sites psite,
     hz_locations loc
WHERE     site.cust_acct_site_id = phne.owner_table_id
      AND phne.owner_table_name = 'HZ_PARTY_SITES'
      AND site.cust_account_id = acct.cust_account_id
      AND site.party_site_id = psite.party_site_id
      AND psite.location_id = loc.location_id
      AND acct.account_number = '1000'

3 comments:

  1. Hello there, I found your site via Google while looking for a related topic, your website came up, it looks great. I have bookmarked it in my google bookmarks. phone mockup

    ReplyDelete
  2. This is so good as warzyd. You should to check it out. He is amazing and can show what things like nobody else. Give him a chance a check. But except i really like your blog. Good job! mobile phone mockup

    ReplyDelete
  3. I take pleasure in you as a consequence of your whole labor on this net website. My niece consider curiosity in managing investigations and it can be straightforward to understand why. My companion and i discover all relating for the dynamic method you make gratifying info by way of your site and also welcome contribution from individuals around the make any difference then our straightforward princess has usually been learning an entire great deal. Get enjoyment inside the relaxation with the new yr. You are the one particular carrying out a wonderful work. iphone sketch

    ReplyDelete