item.txt

Embed Size (px)

DESCRIPTION

item

Citation preview

SELECT distinct decode (hao.organization_id, '593','Oando Gas and Power', '639','Oando Energy Services', '640','Oando Energy Services', '261','Oando Exploration & Production', '262','Oando Marketing Plc', '263','Oando Marketing Plc', '264','Oando Supply & Trading', '265','Oando Group Plc', '266','Oando Marketing Plc', '267','Oando Marketing Plc', '268','Oando Group Plc', '269','Oando Gas and Power', '270','Oando Marketing Plc', '271','Oando Refinery & Terminal', '272','Oando Gas and Power', '273','Oando Energy Services', '274','Oando Supply & Trading', '1517','Oando Exploration & Production', '645','Oando Exploration & Production', '1518','Oando Exploration & Production', '1519','Oando Exploration & Production', '1869','Oando Exploration & Production', '343','Oando Exploration & Production', '344','Oando Exploration & Production', '345','Oando Exploration & Production', '1244','Oando Exploration & Production', '1245','Oando Exploration & Production', '1246','Oando Exploration & Production', '1247','Oando Exploration & Production', '1248','Oando Exploration & Production', '1249','Oando Exploration & Production', '2046','Oando Gas and Power', '2047','Oando Gas and Power', '2048','Oando Gas and Power', '1332','Oando Exploration & Production', '1333','Oando Exploration & Production', '1334','Oando Exploration & Production', '1335','Oando Exploration & Production', '1198','Oando Exploration & Production', '646','Oando Gas and Power', '0', 'Oando PLC', '666','Oando Exploration & Production' ) "Entity", hao.name "Company",--po_release_id , pha.segment1 "BPA Num" ,pra.RELEASE_NUM ,pha.COMMENTS "BPA Desc" ,pha.CREATION_DATE "BPA Creation Date" ,pra.RELEASE_DATE ,pv.VENDOR_NAME Vendor ,pha.BLANKET_TOTAL_AMOUNT "Amount Agreed" ,PHA.CURRENCY_CODE Currency ,NVL((select CONVERSION_RATE from gl_daily_rates where to_currency='NGN' AND from_currency=PHA.CURRENCY_CODE AND CONVERSION_TYPE='Corporate' AND CONVERSION_DATE= (select MAX(CONVERSION_DATE) from gl_daily_rateswhere to_currency='NGN' AND from_currency=PHA.CURRENCY_CODE)),1) Currency_Rate ,SUM (pll.price_override * pll.quantity) "Amount Released" --,0 "Amount Released" ,pav.agent_name "Buyer", pha.authorization_status,pha.APPROVED_DATE BPA_Appro ve_Date , round(((pha.approved_date - pha.CREATION_DATE)* 1),0) BPA_Creatnn_Aprv_Inte rval_Days , round(((pra.RELEASE_DATE - pha.APPROVED_DATE )* 1),0) BPA_Rel_Aprv_Interval _Days ,(select count(release_num) from po_releases_all where po_header_id = pha.po_ header_id and AUTHORIZATION_STATUS ='APPROVED') num_of_releases ,nvl(pha.CLOSED_CODE,'OPEN') CLOSED_CODE FROM po_headers_all pha , po_line_locations_all pll ,po_vendors pv ,po_agents_v pav ,hr_all_organization_units hao ,po_releases_all pra WHERE pll.po_header_id(+) = pha.po_header_id AND pll.po_release_id IS not NULL and pv.VENDOR_ID=pha.VENDOR_ID AND pha.agent_id = pav.agent_id(+) AND pha.TYPE_LOOKUP_CODE = 'BLANKET' and hao.organization_id=pha.org_id and pha.PO_HEADER_ID in (select PO_HEADER_ID from po_releases_all where AU THORIZATION_STATUS ='APPROVED') -- and pha.PO_HEADER_ID not in (select PO_HEADER_ID from po_releases_all whe re AUTHORIZATION_STATUS ='APPROVED') and pha.po_header_id = pra.po_header_id --and pha.PO_HEADER_ID not in (select PO_HEADER_ID from po_releases_all) --AND pha .org_id =273 --and pha.segment1='9445'--'6769' --AND PHA.CURRENCY_CODE in ( 'NGN','USD') GROUP BY pha.segment1,pv.VENDOR_NAME,pha.BLANKET_TOTAL_AMOUNT,pha.COMMENTS, pha.CREATION_DATE,pav.agent_name,hao.organization_id,hao.name,pha.authorization_ status,pha.po_header_id,pha.APPROVED_DATE,pra.RELEASE_NUM,pra.RELEASE_DATE,pha.C LOSED_CODE ,PHA.CURRENCY_CODE--,po_release_id order by 1,2,3,4 -------------------------SELECT distinct decode (hao.organization_id, '593','Oando Gas and Power', '639','Oando Energy Services', '640','Oando Energy Services', '261','Oando Exploration & Production', '262','Oando Marketing Plc', '263','Oando Marketing Plc', '264','Oando Supply & Trading', '265','Oando Group Plc', '266','Oando Marketing Plc', '267','Oando Marketing Plc', '268','Oando Group Plc','269','Oando Gas and Power', '270','Oando Marketing Plc', '271','Oando Refinery & Terminal', '272','Oando Gas and Power', '273','Oando Energy Services', '274','Oando Supply & Trading', '1517','Oando Exploration & Production', '645','Oando Exploration & Production', '1518','Oando Exploration & Production', '1519','Oando Exploration & Production', '1869','Oando Exploration & Production', '343','Oando Exploration & Production', '344','Oando Exploration & Production', '345','Oando Exploration & Production', '1244','Oando Exploration & Production', '1245','Oando Exploration & Production', '1246','Oando Exploration & Production', '1247','Oando Exploration & Production', '1248','Oando Exploration & Production', '1249','Oando Exploration & Production', '2046','Oando Gas and Power', '2047','Oando Gas and Power', '2048','Oando Gas and Power', '1332','Oando Exploration & Production', '1333','Oando Exploration & Production', '1334','Oando Exploration & Production', '1335','Oando Exploration & Production', '1198','Oando Exploration & Production', '646','Oando Gas and Power', '0', 'Oando PLC', '666','Oando Exploration & Production' ) "Entity", hao.name "Company",--po_release_id , pha.segment1 "BPA Num",pha.COMMENTS "BPA Desc",pha.CREATION_DATE "BPA Creatio n Date",pv.VENDOR_NAME Vendor ,pha.BLANKET_TOTAL_AMOUNT "Amount Agreed" ,SUM (pll.price_override * pll.quantity) "Amount Released" --,0 "Amount Released" ,pav.agent_name "Buyer", pha.authorization_status,pha.APPROVED_DATE BPA_Appro ve_Date , round(((pha.approved_date - pha.CREATION_DATE)* 1),0) BPA_Aprv_Interval_Day s ,(select count(release_num) from po_releases_all where po_header_id = pha.po_ header_id and AUTHORIZATION_STATUS ='APPROVED') num_of_releases FROM po_headers_all pha , po_line_locations_all pll ,po_vendors pv ,po_agents_v pav, hr_all_organization_units hao --po_releases_all pra WHERE pll.po_header_id(+) = pha.po_header_id AND pll.po_release_id IS not NULL and pv.VENDOR_ID=pha.VENDOR_ID AND pha.agent_id = pav.agent_id(+) AND pha.TYPE_LOOKUP_CODE = 'BLANKET' and hao.organization_id=pha.org_id and pha.PO_HEADER_ID in (select PO_HEADER_ID from po_releases_all where AU THORIZATION_STATUS ='APPROVED') -- and pha.PO_HEADER_ID not in (select PO_HEADER_ID from po_releases_all whe re AUTHORIZATION_STATUS ='APPROVED')--and pha.po_header_id = pra.po_header_id --and pha.PO_HEADER_ID not in (select PO_HEADER_ID from po_releases_all) -AND pha .org_id =273 --and pha.segment1='6347'--'6769' and pha.authorization_status='APPROVED' GROUP BY pha.segment1,pv.VENDOR_NAME,pha.BLANKET_TOTAL_AMOUNT,pha.COMMENTS, pha.CREATION_DATE,pav.agent_name,hao.organization_id,hao.name,pha.authorization_ status,pha.po_header_id,pha.APPROVED_DATE--,po_release_id --order by 1,2,3 union all SELECT distinct decode (hao.organization_id, '593','Oando Gas and Power', '639','Oando Energy Services', '640','Oando Energy Services', '261','Oando Exploration & Production', '262','Oando Marketing Plc', '263','Oando Marketing Plc', '264','Oando Supply & Trading', '265','Oando Group Plc', '266','Oando Marketing Plc', '267','Oando Marketing Plc', '268','Oando Group Plc', '269','Oando Gas and Power', '270','Oando Marketing Plc', '271','Oando Refinery & Terminal', '272','Oando Gas and Power', '273','Oando Energy Services', '274','Oando Supply & Trading', '1517','Oando Exploration & Production', '645','Oando Exploration & Production', '1518','Oando Exploration & Production', '1519','Oando Exploration & Production', '1869','Oando Exploration & Production', '343','Oando Exploration & Production', '344','Oando Exploration & Production', '345','Oando Exploration & Production', '1244','Oando Exploration & Production', '1245','Oando Exploration & Production', '1246','Oando Exploration & Production', '1247','Oando Exploration & Production', '1248','Oando Exploration & Production', '1249','Oando Exploration & Production', '2046','Oando Gas and Power', '2047','Oando Gas and Power', '2048','Oando Gas and Power', '1332','Oando Exploration & Production', '1333','Oando Exploration & Production', '1334','Oando Exploration & Production', '1335','Oando Exploration & Production', '1198','Oando Exploration & Production', '646','Oando Gas and Power', '0', 'Oando PLC', '666','Oando Exploration & Production' ) "Entity", hao.name "Company",--po_release_id , pha.segment1 "BPA Num",pha.COMMENTS "BPA Desc",pha.CREATION_DATE "BPA Creatio n Date",pv.VENDOR_NAME Vendor ,pha.BLANKET_TOTAL_AMOUNT "Amount Agreed"--,SUM (pll.price_override * pll.quantity) "Amount Released" ,0 "Amount Released" ,pav.agent_name "Buyer", pha.authorization_status,pha.APPROVED_DATE BPA_Ap prove_Date , round(((pha.approved_date - pha.CREATION_DATE)* 1),0) BPA_Aprv_Interval_Day s ,(select count(release_num) from po_releases_all where po_header_id = pha.po_ header_id and AUTHORIZATION_STATUS ='APPROVED') num_of_releases FROM po_headers_all pha , po_line_locations_all pll ,po_vendors pv ,po_agents_v pav, hr_all_organization_units hao WHERE pll.po_header_id(+) = pha.po_header_id --AND pll.po_release_id IS not NULL and pv.VENDOR_ID=pha.VENDOR_ID AND pha.agent_id = pav.agent_id(+) AND pha.TYPE_LOOKUP_CODE = 'BLANKET' and hao.organization_id=pha.org_id and pha.PO_HEADER_ID not in (select PO_HEADER_ID from po_releases_all) -AND pha .org_id =273 --and pha.segment1='6347'--'6769' and pha.authorization_status='APPROVED' GROUP BY pha.segment1,pv.VENDOR_NAME,pha.BLANKET_TOTAL_AMOUNT,pha.COMMENTS,pha.C REATION_DATE, pav.agent_name,hao.organization_id,hao.name,authorization_status,pha.po_header_i d,pha.APPROVED_DATE--,po_release_id order by 1,2,3 ------------------SELECT --(select distinct segment1 from mtl_system_items_b a where a.INVENTORY_ ITEM_ID=pla.item_id ) xx1, -- (select distinct description from mtl_system_items_b a where a.INVENTORY_ITE M_ID=pla.item_id ) xx2, hau.NAME entity ,pla.item_id,pla.LINE_NUM --, po_item_code,pla.po_item_description --,(select distinct a.segment1 from mtl_system_items_b a where a.inven tory_item_id=pla.item_id ) po_item_code --,(select distinct a.description from mtl_system_items_b a where a.i nventory_item_id=pla.item_id ) master_item_description ,pha.segment1 po_num, pha.comments po_item_description, pla.quantity item_line_quantity, pla.unit_price item_line_cost, pla.quantity * pla.unit_price item_amount, pha.creation_date po_date,NV L(pha.APPROVED_FLAG,'N') "Approved ?" FROM --mtl_system_items_b a, hr_all_organization_units hau, po_headers_all pha, po_lines_all pla --,(select a.segment1 po_item_code,a.description master_item_descriptio n, pla.* from po_lines_all pla,mtl_system_items_b a where a.INVENTORY_ITEM_ID=pl a.item_id) pla WHERE hau.organization_id = pha.org_id --AND a.inventory_item_id = pla.item_id -- AND a.organization_id = pla.org_id AND pha.po_header_id = pla.po_header_id AND pha.org_id = pla.org_id --and a.DESCRIPTION LIKE '%S%' and pha.APPROVED_FLAG='Y' and pha.org_id in ('273')-- and pha.SEGMENT1 ='1001' ORDER BY 3------------------SELECT distinct decode (hao.organization_id, '593','Oando Gas and Power', '639','Oando Energy Services', '640','Oando Energy Services', '261','Oando Exploration & Production', '262','Oando Marketing Plc', '263','Oando Marketing Plc', '264','Oando Supply & Trading', '265','Oando Group Plc', '266','Oando Marketing Plc', '267','Oando Marketing Plc', '268','Oando Group Plc', '269','Oando Gas and Power', '270','Oando Marketing Plc', '271','Oando Refinery & Terminal', '272','Oando Gas and Power', '273','Oando Energy Services', '274','Oando Supply & Trading', '1517','Oando Exploration & Production', '645','Oando Exploration & Production', '1518','Oando Exploration & Production', '1519','Oando Exploration & Production', '1869','Oando Exploration & Production', '343','Oando Exploration & Production', '344','Oando Exploration & Production', '345','Oando Exploration & Production', '1244','Oando Exploration & Production', '1245','Oando Exploration & Production', '1246','Oando Exploration & Production', '1247','Oando Exploration & Production', '1248','Oando Exploration & Production', '1249','Oando Exploration & Production', '2046','Oando Gas and Power', '2047','Oando Gas and Power', '2048','Oando Gas and Power', '1332','Oando Exploration & Production', '1333','Oando Exploration & Production', '1334','Oando Exploration & Production', '1335','Oando Exploration & Production', '1198','Oando Exploration & Production', '646','Oando Gas and Power', '0', 'Oando PLC', '666','Oando Exploration & Production' ) "Entity", hao.name "Company", D.SEGMENT1 "PO NUMBER", e.VENDOR_NAME "Vendor Name", TO_DATE (TRUNC (D.CREATION_DATE)) "PO DATE", G.LINE_NUM "Line Num", G.ITEM_DESCRIPTION "LINE DESCRIPTION", (NVL (C.QUANTITY_ORDERED, 0) - NVL (C.QUANTITY_CANCELLED, 0))* NVL (G.UNIT_PRICE, 0) "PO Line Amount", TRUNC(PLL.PROMISED_DATE) "PROMISED DATE", D.currency_code "Currency", D.AUTHORIZATION_STATUS "Status" FROM PO_DISTRIBUTIONS_ALL C, PO_HEADERS_ALL D, PO_VENDORS E, PO_VENDOR_SITES_ALL F, PO_LINES_ALL G, HR_ALL_ORGANIZATION_UNITS HAO, PO_LINE_LOCATIONS_ALL PLL WHERE C.PO_HEADER_ID = D.PO_HEADER_ID(+) AND E.VENDOR_ID(+) = D.VENDOR_ID AND F.VENDOR_SITE_ID(+) = D.VENDOR_SITE_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 D.TYPE_LOOKUP_CODE != 'BLANKET' AND PLL.PO_HEADER_ID=D.PO_HEADER_ID AND PLL.PO_LINE_ID=G.PO_LI AND PLL.ORG_ID=D.ORG_ID AND D.ORG_ID=hao.organization_id D.SEGMENT1 ='5535' d.org_id='273' -- AND TRUNC(D.CREATION_DATE) BETWEEN SYSDATE-365 AND SYSDATE by 1,2,3NE_ID --and --and order----------------------SELECT distinct decode (hao.organization_id, '593','Oando Gas and Power', '639','Oando Energy Services', '640','Oando Energy Services', '261','Oando Exploration & Production', '262','Oando Marketing Plc', '263','Oando Marketing Plc', '264','Oando Supply & Trading', '265','Oando Group Plc', '266','Oando Marketing Plc', '267','Oando Marketing Plc', '268','Oando Group Plc', '269','Oando Gas and Power', '270','Oando Marketing Plc', '271','Oando Refinery & Terminal', '272','Oando Gas and Power', '273','Oando Energy Services', '274','Oando Supply & Trading', '1517','Oando Exploration & Production', '645','Oando Exploration & Production', '1518','Oando Exploration & Production', '1519','Oando Exploration & Production', '1869','Oando Exploration & Production', '343','Oando Exploration & Production', '344','Oando Exploration & Production', '345','Oando Exploration & Production', '1244','Oando Exploration & Production','1245','Oando Exploration & Production', '1246','Oando Exploration & Production', '1247','Oando Exploration & Production', '1248','Oando Exploration & Production', '1249','Oando Exploration & Production', '2046','Oando Gas and Power', '2047','Oando Gas and Power', '2048','Oando Gas and Power', '1332','Oando Exploration & Production', '1333','Oando Exploration & Production', '1334','Oando Exploration & Production', '1335','Oando Exploration & Production', '1198','Oando Exploration & Production', '646','Oando Gas and Power', '0', 'Oando PLC', '666','Oando Exploration & Production' ) "Entity", hao.name "Company", D.SEGMENT1 "PO NUMBER", e.VENDOR_NAME "Vendor Name", TO_DATE (TRUNC (D.CREATION_DATE)) "PO DATE", G.LINE_NUM "Line Num", C.DESTINATION_ORGANIZATION_ID,c.DESTINATION_TYPE_CODE, a.segment1 po_item_code, a.description master_item_description, --g.quantity * g.unit_price item_amount, G.ITEM_DESCRIPTION, d.creation_date po_date, NVL(d.APPROVED_FLAG,'N') "Approved ?", (NVL (C.QUANTITY_ORDERED, 0) - NVL (C.QUANTITY_CANCELLED, 0)) .UNIT_PRICE, 0) PO_Line_Item_Amount, TRUNC(PLL.PROMISED_DATE) "PROMISED DATE", D.currency_code "Currency", D.AUTHORIZATION_STATUS "Status" FROM PO_DISTRIBUTIONS_ALL C, PO_HEADERS_ALL D, PO_VENDORS E, PO_VENDOR_SITES_ALL F, PO_LINES_ALL G, HR_ALL_ORGANIZATION_UNITS HAO, PO_LINE_LOCATIONS_ALL PLL, mtl_system_items_b a WHERE* NVL (Ga.inventory_item_id = g.item_id and a.organization_id = c.DESTINATION_ORGANIZATION_ID and C.PO_HEADER_ID = D.PO_HEADER_ID(+) AND E.VENDOR_ID(+) = D.VENDOR_ID AND F.VENDOR_SITE_ID(+) = D.VENDOR_SITE_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 D.TYPE_LOOKUP_CODE != 'BLANKET' AND PLL.PO_HEADER_ID=D.PO_HEADER_ID AND PLL.PO_LINE_ID=G.PO_LI NE_ID AND PLL.ORG_ID=D.ORG_ID AND D.ORG_ID=hao.organization_id and D.SEGMENT1 ='5535' and d.org_id='273' -- AND TRUNC(D.CREATION_DATE) BETWEEN SYSDATE-365 AND SYSDATEorder by 1,2,3,6 ---------------SELECT hau.NAME entity ,a.segment1 po_item_code, a.description master_item_description, pha.segment1 po_num, pha.comments po_item_description, pla.quantity item_line_quantity, pla.unit_price item_line_cost, pla.quantity * pla.unit_price item_amount, pha.creation_date po_date,NV L(pha.APPROVED_FLAG,'N') "Approved ?" FROM mtl_system_items_b a, hr_all_organization_units hau, po_headers_all pha, po_lines_all pla WHERE hau.organization_id = pha.org_id AND a.inventory_item_id = pla.item_id AND a.organization_id = pla.org_id AND pha.po_header_id = pla.po_header_id AND pha.org_id = pla.org_id --and a.DESCRIPTION LIKE '%S%' --and pha.org_id in ('262') --and pha.SEGMENT1 ='6567' ORDER BY 3