AP Invoice with PO information
Hi All,
My query is getting duplicate values i have kept all the join conditions correctly.please let me know its urgent.Advance thanks i am pasting the query.
select HL.LOCATION_CODE "LOCATION CODE",
HL.DESCRIPTION "DESCRIPTION",
aid.period_name "PERIOD NAME",
pll.line_location_id "HEADING",
glcc.CONCATENATED_SEGMENTS "DIST ACCOUNT NBR",
to_char(aia.invoice_date,'DD-MM-YYYY') "INVOICE DATE",
aia.voucher_num "VOUCHER NUMBER",
pv.segment1 "VENDOR NUMBER",
pv.vendor_name "VENDOR NAME",
msi.segment1 "PART NUMBER",
msi.description "PART DESCRIPTION",
pl.unit_meas_lookup_code "UNIT OF MEASURE",
pl.quantity "QUANTITY",
ph.segment1 "PO",
rsh.receipt_num "RECEIPT NUMBER",
pr.release_num"RELEASE NUMBER",
aia.INVOICE_AMOUNT "AMOUNT",
aid.amount "LINE AMOUNT"
from
po_headers_all ph,
po_lines_all pl,
po_line_locations_all pll,
po_distributions_all pd,
po_releases_all pr,
rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
po_vendors pv,
ap_invoices_all aia,
ap_invoice_distributions_all aid,
mtl_system_items_b msi,
gl_code_combinations_kfv glcc,
hr_locations_all hl
where ph.po_header_id = pl.po_header_id
AND pl.po_line_id = pll.po_line_id
AND pl.po_line_id = pd.po_line_id
AND rsh.shipment_header_id = rsl.shipment_header_id
AND rsl.po_header_id = ph.po_header_id
AND pr.po_header_id = ph.po_header_id
AND pd.po_distribution_id =aid.po_distribution_id
and aia.invoice_id = aid.invoice_id
AND pv.vendor_id = aia.vendor_id
AND glcc.CODE_COMBINATION_ID = aid.DIST_CODE_COMBINATION_ID
AND msi.inventory_item_id = pl.item_id
AND HL.LOCATION_ID =pll.line_location_id
--- and porg_id = 7404
AND rownum<50