select distinct hca.account_number ,
hcsu.cust_acct_site_id, hcsu.site_use_id,
hps.party_site_number ,
hp.party_name , hl1.address1 street1,
hl1.address2 street2, hl1.address3 street3,
hl1.address4 street4, hl1.house_number house, hl1.city,
hl1.postal_code,
decode (hcp.phone_line_type,
'gen', hcp.phone_area_code || hcp.phone_number,
null
) phone_number,
hl1.country, hl1.state region,
decode (hcp.phone_line_type,
'fax', hcp.phone_area_code || hcp.phone_number,
null
) fax_number,
hp.email_address
from hz_parties hp,
hz_locations hl1,
hz_cust_site_uses_all hcsu,
hz_cust_acct_sites_all hcas,
hz_party_sites hps,
hz_cust_accounts hca,
hz_contact_points hcp
where 1 = 1
and hcsu.cust_acct_site_id = hcas.cust_acct_site_id
and hcas.party_site_id = hps.party_site_id
and hps.location_id = hl1.location_id
and hp.party_id = hcp.owner_table_id(+)
and hp.party_id = hps.party_id
and hca.cust_account_id = hcas.cust_account_id
and hcsu.site_use_code = 'bill_to'
-- and hp.party_name like 'a%'
order by hp.party_name;
No comments:
Post a Comment