/* Formatted on 09-08-2011 10:37:44 (QP5 v5.115.810.9015) */
SELECT
distinct --SUM (aia.INVOICE_AMOUNT)
aia.invoice_id,
aia.invoice_num,
(SELECT name
FROM hr_operating_units
WHERE organization_id = aid.org_id)
Operating_Unit,
aia.INVOICE_NUM L_INVOICE_NUM,
aid.DISTRIBUTION_LINE_NUMBER L_LINE_NUMBER,
aid.LINE_TYPE_LOOKUP_CODE L_LINE_TYPE,
aid.DESCRIPTION L_DESCRIPTION,
aia.INVOICE_AMOUNT,
aid.AMOUNT L_AMOUNT,
aid.QUANTITY_INVOICED L_QUANTITY,
' ' L_UOM,
aid.UNIT_PRICE L_UNIT_PRICE,
glcc.CONCATENATED_SEGMENTS L_DIST_ACCOUNT,
'' L_ATTR_CONTEXT,
' ' ATTRIBUTE1,
' ' ATTRIBUTE2,
' ' ATTRIBUTE3,
'' ATTRIBUTE4,
Aia.INVOICE_ID ATTRIBUTE5,
aia.DOC_SEQUENCE_ID,
aia.DOC_SEQUENCE_VALUE
FROM ap_invoices_all aia,
apps.po_vendors pov,
hr_operating_units hou,
apps.ap_terms_tl term,
apps.po_vendor_sites_all sites,
apps.gl_code_combinations_kfv glcc,
ap_invoice_distributions_all aid
WHERE aia.vendor_id = pov.vendor_id
AND hou.organization_id = aia.org_id
AND aia.terms_id = term.term_id
AND aia.vendor_site_id = sites.vendor_site_id
--AND aia.accts_pay_code_combination_id = glcc.code_combination_id
AND aia.set_of_books_id = 5
AND aia.invoice_id = aid.invoice_id
AND aid.DIST_CODE_COMBINATION_ID = glcc.CODE_COMBINATION_ID
AND TRUNC (aia.GL_DATE) BETWEEN '01-APR-2011' AND '30-JUN-2011'
--AND TRUNC (aia.INVOICE_DATE) BETWEEN '01-APR-2011' AND '30-JUN-2011'
--AND (aia.INVOICE_AMOUNT - aia.AMOUNT_PAID) > 0
AND aia.invoice_type_lookup_code = 'PREPAYMENT'
--AND aid.LINE_TYPE_LOOKUP_CODE NOT IN ('PREPAY', 'AWT')
/* AND AIA.INVOICE_ID IN
( SELECT DISTINCT invoice_id FROM xx_invoice_id1) */
ORDER BY aia.invoice_id--, aia.INVOICE_DATE
SELECT
distinct --SUM (aia.INVOICE_AMOUNT)
aia.invoice_id,
aia.invoice_num,
(SELECT name
FROM hr_operating_units
WHERE organization_id = aid.org_id)
Operating_Unit,
aia.INVOICE_NUM L_INVOICE_NUM,
aid.DISTRIBUTION_LINE_NUMBER L_LINE_NUMBER,
aid.LINE_TYPE_LOOKUP_CODE L_LINE_TYPE,
aid.DESCRIPTION L_DESCRIPTION,
aia.INVOICE_AMOUNT,
aid.AMOUNT L_AMOUNT,
aid.QUANTITY_INVOICED L_QUANTITY,
' ' L_UOM,
aid.UNIT_PRICE L_UNIT_PRICE,
glcc.CONCATENATED_SEGMENTS L_DIST_ACCOUNT,
'' L_ATTR_CONTEXT,
' ' ATTRIBUTE1,
' ' ATTRIBUTE2,
' ' ATTRIBUTE3,
'' ATTRIBUTE4,
Aia.INVOICE_ID ATTRIBUTE5,
aia.DOC_SEQUENCE_ID,
aia.DOC_SEQUENCE_VALUE
FROM ap_invoices_all aia,
apps.po_vendors pov,
hr_operating_units hou,
apps.ap_terms_tl term,
apps.po_vendor_sites_all sites,
apps.gl_code_combinations_kfv glcc,
ap_invoice_distributions_all aid
WHERE aia.vendor_id = pov.vendor_id
AND hou.organization_id = aia.org_id
AND aia.terms_id = term.term_id
AND aia.vendor_site_id = sites.vendor_site_id
--AND aia.accts_pay_code_combination_id = glcc.code_combination_id
AND aia.set_of_books_id = 5
AND aia.invoice_id = aid.invoice_id
AND aid.DIST_CODE_COMBINATION_ID = glcc.CODE_COMBINATION_ID
AND TRUNC (aia.GL_DATE) BETWEEN '01-APR-2011' AND '30-JUN-2011'
--AND TRUNC (aia.INVOICE_DATE) BETWEEN '01-APR-2011' AND '30-JUN-2011'
--AND (aia.INVOICE_AMOUNT - aia.AMOUNT_PAID) > 0
AND aia.invoice_type_lookup_code = 'PREPAYMENT'
--AND aid.LINE_TYPE_LOOKUP_CODE NOT IN ('PREPAY', 'AWT')
/* AND AIA.INVOICE_ID IN
( SELECT DISTINCT invoice_id FROM xx_invoice_id1) */
ORDER BY aia.invoice_id--, aia.INVOICE_DATE
No comments:
Post a Comment