SQL Sample Statement

Determine purchase orders which are still open for a business unit.

				
					SELECT
    fbu.bu_name              procurement_business_unit,
    poh.segment1             po_number,
    trunc(poh.creation_date) po_creation_date,
    pol.line_num             line_number,
    pol.item_description     item_description,
    pol.list_price           line_list_price,
    pv.segment1              supplier_number,
    pvs.vendor_site_code     supplier_site_code
FROM
         po_headers_all poh
    INNER JOIN po_lines_all                 pol ON poh.po_header_id = pol.po_header_id
                               AND coalesce(poh.document_status, 'OPEN') IN ( 'OPEN' )
    INNER JOIN poz_suppliers            pv ON poh.vendor_id = pv.vendor_id
    INNER JOIN fun_all_business_units_v fbu ON fbu.bu_id = poh.prc_bu_id
    INNER JOIN poz_supplier_sites_all_m pvs ON poh.vendor_site_id = pvs.vendor_site_id
WHERE
        1 = 1
    AND fbu.bu_name = :Business_Unit