|
|
发表于 2010/1/25 09:58:07
|
显示全部楼层
select TEMP.party_name ,
TEMP.vendor_number,
TEMP.vendor_id ,
TEMP.num_1099 ,
TEMP.vat_registration_num ,
TEMP.paid_to_name ,
TEMP.active ,
TEMP.auto_calculate_interest_flag ,
TEMP.num_active_pay_sites,
TEMP.num_inactive_pay_sites,
TEMP.party_id ,
TEMP.payment_function ,
TEMP.vendor_type_lookup_code
from ( select hp.party_name party_name,
asup.segment1 vendor_number,
asup.vendor_id vendor_id,
asup.num_1099 num_1099,
asup.vat_registration_num vat_registration_num,
hp.party_name paid_to_name,
DECODE(SIGN(TO_DATE(TO_CHAR(START_DATE_ACTIVE,'DD-MM-YYYY'),
'DD-MM-YYYY') - TO_DATE(TO_CHAR(SYSDATE,'DD-MM-YYYY'),'DD-MM-YYYY')),
1, '', DECODE(SIGN(TO_DATE(TO_CHAR(END_DATE_ACTIVE ,'DD-MM-YYYY'),
'DD-MM-YYYY') - TO_DATE(TO_CHAR(SYSDATE,'DD-MM-YYYY'),'DD-MM-YYYY')),
-1, '', 0, '', '*')) active,
asup.auto_calculate_interest_flag auto_calculate_interest_flag ,
null num_active_pay_sites,
null num_inactive_pay_sites,
asup.party_id party_id ,
iep.payment_function payment_function,
asup.vendor_type_lookup_code vendor_type_lookup_code
from ap_suppliers asup,
iby_external_payees_all iep,
hz_parties hp
where ((:parameter.pay_in_full_party_id is null and asup.party_id=iep.payee_party_id)
or (:parameter.pay_in_full_party_id is not null and asup.party_id=:parameter.pay_in_full_party_id))
and ((:parameter.pay_in_full_payment_function is null and iep.payment_function = iep.payment_function)
or (:parameter.pay_in_full_payment_function is not null and iep.payment_function = :parameter.pay_in_full_payment_function))
and asup.party_id = iep.payee_party_id
and asup.party_id = hp.party_id
group by hp.party_name, segment1, vendor_id, num_1099, vat_registration_num,
DECODE(SIGN(TO_DATE(TO_CHAR(START_DATE_ACTIVE,'DD-MM-YYYY'),
'DD-MM-YYYY') - TO_DATE(TO_CHAR(SYSDATE,'DD-MM-YYYY'),'DD-MM-YYYY')),
1, '', DECODE(SIGN(TO_DATE(TO_CHAR(END_DATE_ACTIVE ,'DD-MM-YYYY'),
'DD-MM-YYYY') - TO_DATE(TO_CHAR(SYSDATE,'DD-MM-YYYY'),'DD-MM-YYYY')),
-1, '', 0, '', '*')),
auto_calculate_interest_flag,
asup.party_id,
payment_function,
asup.vendor_type_lookup_code
UNION
select /*+ INDEX(hp HZ_PARTIES_U1) no_expand */ hp.party_name party_name,
null vendor_number,
null vendor_id,
hp.jgzz_fiscal_code num_1099,
hp.tax_reference vat_registration_num,
hp.party_name paid_to_name,
null active,
null auto_calculate_interest_flag,
null num_active_pay_sites,
null num_inactive_pay_sites,
hp.party_id party_id,
iep.payment_function payment_function,
null vendor_type_lookup_code
from hz_parties hp,
iby_external_payees_all iep
where hp.party_id = nvl(:parameter.pay_in_full_party_id, iep.payee_party_id)
and iep.payment_function = nvl(:parameter.pay_in_full_payment_function,
iep.payment_function)
and hp.party_id = iep.payee_party_id
and not exists (select 'x'
from ap_suppliers asup
where asup.party_id = iep.payee_party_id)
group by hp.party_name, hp.jgzz_fiscal_code, hp.tax_reference, hp.party_id,
iep.payment_function
order by 1 ) TEMP
where 1=1 |
|