Query to find the AP invoices that are applied to multiple Purchase Orders

Query to find the AP invoices that are applied to multiple Purchase Orders
Oracle apps ebs sql to find the AP invoices that are applied to multiple Purchase Orders
  SELECT COUNT (DISTINCT d.segment1), a.invoice_num
    FROM ap.ap_invoices_all            A,
         ap.ap_invoice_distributions_all b,
         po.po_distributions_all       C,
         po.po_headers_all             d,
         po.po_lines_all               G
   WHERE     a.invoice_id = b.invoice_id
         AND b.po_distribution_id = c.po_distribution_id(+)
         AND c.po_header_id = d.po_header_id(+)
         AND d.po_header_id = g.po_header_id
         AND c.po_line_id = g.po_line_id
         AND c.po_header_id IS NOT NULL
         AND a.payment_status_flag = 'Y'
         AND d.type_lookup_code != 'BLANKET'
         AND a.org_id = 1234
         AND a.org_id = d.org_id
GROUP BY a.invoice_num
  HAVING COUNT (DISTINCT d.segment1) > 1
Related posts: Upload your own post and refer it anywhere anytime:

Leave a Reply