Thursday, April 10, 2008

Available phones/emails/web for an account


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'

No comments:

Post a Comment