Good SQL Collections
Good SQL Collections
Good SQL Collections
AP_RECON_DISTRIBUTIONS_ALL
SELECT *
FROM AP_RECON_DISTRIBUTIONS_ALL
WHERE check_id IN
( SELECT check_id
FROM AP_INVOICE_PAYMENTS_ALL
WHERE invoice_id = '166014'
);
AP_DOCUMENTS_PAYABLE
SELECT
pay_proc_trxn_type_code,
calling_app_doc_unique_ref1 check_id,
calling_app_doc_unique_ref2 invoice_id,
calling_app_doc_unique_ref4 invoice_payment_id,
calling_app_doc_ref_number invoice_number,
payment_function,
payment_date,
document_date,
document_type,
payment_currency_code,
payment_amount,
payment_method_code
FROM
AP_DOCUMENTS_PAYABLE
WHERE calling_app_id = 200 -- Application id for Payables
AND calling_app_doc_unique_ref2 = '166014';
IBY_DOCS_PAYABLE_ALL
SELECT *
FROM IBY_DOCS_PAYABLE_ALL
WHERE calling_app_id = 200
AND calling_app_doc_unique_ref2 = '166014';
IBY_PAYMENTS_ALL
SELECT *
FROM IBY_PAYMENTS_ALL
WHERE payment_id IN
(SELECT payment_id
FROM IBY_DOCS_PAYABLE_ALL
WHERE calling_app_id = 200
AND calling_app_doc_unique_ref2 = '166014'
);
IBY_PAY_INSTRUCTIONS_ALL
SELECT *
FROM IBY_PAY_INSTRUCTIONS_ALL
WHERE payment_instruction_id IN
(SELECT payment_instruction_id
FROM IBY_PAYMENTS_ALL
WHERE payment_id IN
(SELECT payment_id
FROM IBY_DOCS_PAYABLE_ALL
WHERE calling_app_id = 200
AND calling_app_doc_unique_ref2 = '166014'
);
);
SELECT
hou.name AP_BUSINESS_UNIT,
pv.SEGMENT1 SupplierID,
hp.PARTY_NAME Name,
aia.SOURCE origin,
aia.invoice_num,
aia.invoice_Date,
aia.INVOICE_AMOUNT,
aia.invoice_currency_code,
TO_CHAR(aia.creation_date, 'MM/DD/YYYY') invoice_creation_date,
TO_CHAR(aia.LAST_UPDATE_DATE, 'MM/DD/YYYY') invoice_last_updated_date,
aia.LAST_UPDATED_BY LAST_UPDATED_BY,
glcc.segment1 company,
glcc.segment2 account,
glcc.segment3 gl_function,
glcc.segment4 cost_center,
glcc.segment5 project,
glcc.segment6 future1,
glcc.segment7 future2
FROM
ap_invoices_all aia,
ap_invoice_lines_all ail,
ap_invoice_distributions_all aid,
poz_suppliers pv,
poz_supplier_sites_all_m sia,
hz_parties hp,
hr_all_organization_units hou,
gl_code_combinations glcc
WHERE
aia.invoice_id=ail.invoice_id
AND aia.invoice_id = aid.invoice_id
and aid.invoice_line_number = ail.line_number
AND sia.vendor_id = pv.vendor_id
AND sia.vendor_site_id = aia.vendor_site_id
AND sia.prc_bu_id = hou.organization_id
AND pv.vendor_id = aia.vendor_id
AND pv.party_id = hp.party_id
AND aid.dist_code_combination_id = glcc.code_combination_id
and aia.invoice_num like 'CAR000%'
and glcc.segment2 = '203402'