select rt.name, hcas.org_id
from ar.hz_cust_acct_sites_all hcas,
ar.hz_cust_site_uses_all hcsu,
ra_terms_vl rt
where 1 = 1
and hcas.status = 'A'
and hcsu.status = 'A'
and hcsu.cust_acct_site_id = hcas.cust_acct_site_id
and hcsu.site_use_code = 'BILL_TO' --ShIP_TO
and rt.term_id = hcsu.payment_term_id
and rt.name is not null
and hcas.cust_account_id = 13434343 -- hca.cust_account_id--cusomter_id
select hl.address1 || ', ' || hl.address2 地址,
hou.name 业务实体,
decode(hcsua2.site_use_code,
'BILL_TO',
'收单方',
'DRAWEE',
'付款人',
'SHIP_TO',
'收货方') 相关人
from hz_cust_acct_sites_all cas,
apps.hz_cust_site_uses_all hcsua2,
hz_party_sites hps,
hz_locations hl,
hr_operating_units hou
where cas.party_site_id = hps.party_site_id
and hps.location_id = hl.location_id
and cas.org_id = hou.organization_id
and hcsua2.cust_acct_site_id = cas.cust_acct_site_id
and hcsua2.primary_flag = 'Y'
and cas.cust_account_id = 134343 --CUSTOMER_ID