Вы находитесь на странице: 1из 2

SELECT SUM(RATE*QUANTITY) FROM( select 'PO' TYPE,currency_code,poh.segment1 po_number ,(pol.UNIT_PRICE*nvl(poh.r ate,1)) rate,pol.

quantity, 0 PO,AUTHORIZATION_STATUS from po_headers_all poh, po_lines_all pol, po_distributions_all pod where pod.project_id in (select project_id From pa_projects_all where segment1=:porjec t_no) and poh.po_header_id = pol.po_header_id and pol.po_line_id = pod.po_line_id AND AUTHORIZATION_STATUS !='REJECTED' UNION ALL select 'PRS' TYPE,null, prh.segment1 req_no,prl.UNIT_PRICE,prl.quantity,prl.lin e_location_id,AUTHORIZATION_STATUS from po_req_distributions_all prd, po_requisition_lines_all prl, po_requisition_headers_all prh where prd.project_id in (select project_id From pa_projects_all where segment1=: porject_no) and prh.requisition_header_id = prl.requisition_header_id and prl.requisition_line_id = prd.requisition_line_id and prl.line_location_id is null AND AUTHORIZATION_STATUS NOT IN ('RETURNED','REJECTED') ) A ----------------------------MULTIPLE PROJECTS ----------------------------select 'PO' TYPE,currency_code,poh.segment1 po_number ,(pol.UNIT_PRICE*nvl(poh.r ate,1)) rate,pol.quantity, 0 PO,AUTHORIZATION_STATUS,ppa.segment1 project_no fro m po_headers_all poh, po_lines_all pol, po_distributions_all pod , pa_projects_all ppa where pod.project_id =ppa.project_id and ppa.segment1 in('10828','11347') an d poh.po_header_id = pol.po_header_id and pol.po_line_id = pod.po_line_id AND AUTHORIZATION_STATUS !='REJECTED' UNION ALL select 'PRS' TYPE,null, prh.segment1 req_no,prl.UNIT_PRICE,prl.quantity,prl.lin e_location_id,AUTHORIZATION_STATUS,ppa.segment1 project_no from po_req_distributions_all prd, po_requisition_lines_all prl, po_requisition_headers_all prh, pa_projects_all ppa where prd.project_id =ppa.project_id and ppa.segment1 in('10828','11347') an d prh.requisition_header_id = prl.requisition_header_id and prl.requisition_line_id = prd.requisition_line_id and prl.line_location_id is null AND AUTHORIZATION_STATUS NOT IN ('RETURNED','REJECTED')

---------------------------------------

select currency_code,poh.segment1 po_number ,(pol.UNIT_PRICE*nvl(poh.rate,1)) ra te,pol.quantity, 0 PO,AUTHORIZATION_STATUS from po_headers_all poh, po_lines_all pol, po_distributions_all pod where pod.project_id in (select project_id From pa_projects_all where segment1=:porjec t_no) and poh.po_header_id = pol.po_header_id and pol.po_line_id = pod.po_line_id UNION ALL select null, prh.segment1 req_no,prl.UNIT_PRICE,prl.quantity,prl.line_location_i d,AUTHORIZATION_STATUS from po_req_distributions_all prd, po_requisition_lines_all prl, po_requisition_headers_all prh where prd.project_id in (select project_id From pa_projects_all where segment1=: porject_no) and prh.requisition_header_id = prl.requisition_header_id and prl.requisition_line_id = prd.requisition_line_id and prl.line_location_id is null

Вам также может понравиться