Tuesday, 30 September 2014

Cancel Purchase Order Query

select distinct a.po_header_id,
       c.item_id,
       c.item_description,
       a.quantity QTY_REJECTED,
       b.quantity QTY_RETURNED,
       a.transaction_date REJECTED_DATE,
       b.transaction_date RETURNED_DATE,
       b.transaction_date-a.transaction_date Days,
       e.vendor_name
from
    (select po_header_id,quantity,transaction_type,transaction_date from po.rcv_transactions      where
     transaction_type in ('REJECT')) a,
     (select po_header_id,quantity,transaction_type,transaction_date from po.rcv_transactions where
     transaction_type in ('RETURN TO VENDOR')) b,
   po.po_lines_all c,
   po.po_headers_all d,
   po.po_vendors e
   where a.po_header_id=b.po_header_id and
   a.po_header_id=c.po_header_id and
   a.po_header_id=d.po_header_id and
   d.vendor_id=e.vendor_id and
   e.vendor_name=:vendorname

No comments:

Post a Comment