Tuesday 10 December 2013

Invoice without po

  SELECT   aia.invoice_num, NVL (SUM (aid.amount), 0)
    FROM   ap_invoice_distributions_all aid,
           ap_invoice_lines_all aii,
           ap_invoices_all aia
   WHERE       1 = 1
           AND aid.invoice_id = aii.invoice_id
           AND (aid.cancellation_flag <> 'Y' OR aid.cancellation_flag IS NULL)
           AND (aii.cancelled_flag <> 'Y' OR aii.cancelled_flag IS NULL)
           AND aid.invoice_id = aia.invoice_id
           AND aia.cancelled_date IS NULL
           AND aii.line_number = aid.invoice_line_number
           AND NOT EXISTS
                 (SELECT   pod.po_distribution_id
                    FROM   po_distributions_all pod
                   WHERE   pod.po_distribution_id = aid.po_distribution_id)
--           AND aid.project_id = 123
           AND aid.match_status_flag = 'T'
GROUP BY   aia.invoice_num

No comments:

Post a Comment