0% found this document useful (0 votes)
88 views

Data Validation Query

The document contains SQL statements to: 1. Create a table called xxddk_fifo_pd_ti_data by selecting and ranking data from other tables based on certain conditions. 2. Create another table called xxddk_fifo_pd_ti_x_peg_data by selecting data from msc_full_pegging and msc_supplies tables where certain conditions are met. 3. Select data from the xxddk_fifo_pd_ti_data table where there is a match to the xxddk_fifo_pd_ti_x_peg_data table and order the results.

Uploaded by

dipakdkulkarni
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

Data Validation Query

The document contains SQL statements to: 1. Create a table called xxddk_fifo_pd_ti_data by selecting and ranking data from other tables based on certain conditions. 2. Create another table called xxddk_fifo_pd_ti_x_peg_data by selecting data from msc_full_pegging and msc_supplies tables where certain conditions are met. 3. Select data from the xxddk_fifo_pd_ti_data table where there is a match to the xxddk_fifo_pd_ti_x_peg_data table and order the results.

Uploaded by

dipakdkulkarni
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

create table xxddk_fifo_pd_ti_data as

select * from (
SELECT RANK ()
OVER (PARTITION BY P.INVENTORY_ITEM_ID, P.organization_id
ORDER BY TRUNC (p.DEMAND_DATE))
DMD,
RANK ()
OVER (PARTITION BY P.INVENTORY_ITEM_ID, P.organization_id
ORDER BY TRUNC (p.SUPPLY_DATE))
sup,
p.DEMAND_DATE,p.SUPPLY_DATE,
p.ATTRIBUTE1,
--p.ATTRIBUTE2,
--p.ATTRIBUTE3,
i.ITEM_NAME, i.postprocessing_lead_time pplt,
p.PEGGING_ID,
p.DEMAND_ID,
md.order_number dmd_number,
p.END_ORIGINATION_TYPE dmd_type,
p.DEMAND_QUANTITY dmd_qty,
p.TRANSACTION_ID,
p.SUPPLY_TYPE,
ms.order_number supply_number,
p.SUPPLY_QUANTITY,
TRUNC (GREATEST (NVL (ms.promised_date, SYSDATE))) promised_Date,
p.INVENTORY_ITEM_ID,
p.ORGANIZATION_ID,
p.PLAN_ID
FROM apps.msc_full_pegging p,
apps.xxscp_gbl_cust_plan_items xi,
apps.msc_system_items i,
apps.msc_supplies ms,
apps.msc_demands md
WHERE p.plan_id = 4021
AND p.INVENTORY_ITEM_ID = xi.INVENTORY_ITEM_ID
AND p.ORGANIZATION_ID = xi.ORGANIZATION_ID
AND p.PLAN_ID = xi.PLAN_ID
AND i.INVENTORY_ITEM_ID = xi.INVENTORY_ITEM_ID
AND i.ORGANIZATION_ID = xi.ORGANIZATION_ID
AND i.PLAN_ID = xi.PLAN_ID
--AND p.INVENTORY_ITEM_ID = 3314434
--AND i.ITEM_NAME LIKE '69253-001LF^FCI'
AND ms.plan_id = p.plan_id
AND ms.ORGANIZATION_ID = p.ORGANIZATION_ID
AND p.ATTRIBUTE1 NOT IN ('P-EXCESS', 'P0-RES', 'P00-IF', 'P01-
IF','P01-ELSE')
AND ms.inventory_item_id = p.inventory_item_id
AND ms.transaction_id = p.transaction_id
and md.plan_id = p.plan_id
and md.inventory_item_id = p.inventory_item_id
and md.organization_id = p.organization_id
and md.demand_id = p.demand_id
AND EXISTS
(select 1 from apps.XXSCP_GBL_RELEASE_LINES_AD RWB WHERE
RWB.MANUFACTURER_CODE = 'TI'
AND RWB.INVENTORY_ITEM_ID = p.inventory_item_id
AND RWB.ORGANIZATION_ID = p.organization_id)
)
order by PLAN_ID, ORGANIZATION_ID, INVENTORY_ITEM_ID, dmd,sup
create table xxddk_fifo_pd_ti_x_peg_data as
(SELECT mfp.inventory_item_id,
mfp.organization_id
--, mfp.demand_id,mfp.END_ORIGINATION_TYPE, mfp.demand_date,
mfp.DEMAND_QUANTITY, mfp.transaction_id,mfp.SUPPLY_TYPE, ms.promised_date,
mfp.SUPPLY_QUANTITY , TRUNC (GREATEST (ms.promised_date, SYSDATE)), mfp.attribute1
FROM apps.msc_full_pegging mfp, apps.msc_supplies ms
WHERE 1=1
--and mfp.inventory_item_id = x.INVENTORY_ITEM_ID
--AND mfp.organization_id = x.organization_id
AND mfp.plan_id = 4021
AND mfp.inventory_item_id = ms.inventory_item_id
AND mfp.organization_id = ms.organization_id
AND mfp.plan_id = ms.plan_id
AND mfp.sr_instance_id = ms.sr_instance_id
AND mfp.transaction_id = ms.transaction_id
and mfp.ATTRIBUTE1 not in ('P-EXCESS','P0-RES','P00-IF', 'P01-IF', 'P01-
ELSE')
AND EXISTS
(SELECT 1
FROM apps.msc_full_pegging mfp1, apps.msc_supplies ms1
WHERE 1 = 1
AND mfp1.inventory_item_id = ms1.inventory_item_id
AND mfp1.organization_id = ms1.organization_id
AND mfp1.plan_id = ms1.plan_id
AND mfp1.sr_instance_id = ms1.sr_instance_id
AND mfp1.transaction_id = ms1.transaction_id
AND mfp.inventory_item_id = mfp1.inventory_item_id
AND mfp.organization_id = mfp1.organization_id
AND mfp.plan_id = mfp1.plan_id
AND mfp.sr_instance_id = mfp1.sr_instance_id
AND TRUNC (GREATEST (ms.promised_Date, SYSDATE)) < TRUNC
(GREATEST (ms1.promised_date, SYSDATE))
AND TRUNC (GREATEST (mfp.demand_date, SYSDATE)) > TRUNC
(GREATEST (mfp1.demand_date, SYSDATE))
and mfp.ATTRIBUTE1 not in ('P-EXCESS','P0-RES','P00-IF',
'P01-IF', 'P01-ELSE')
)
AND EXISTS
(select 1 from apps.XXSCP_GBL_RELEASE_LINES_AD RWB WHERE
RWB.MANUFACTURER_CODE = 'TI'
AND RWB.INVENTORY_ITEM_ID = mfp.inventory_item_id
AND RWB.ORGANIZATION_ID = mfp.organization_id)
--order by mfp.organization_id, mfp.inventory_item_id, mfp.demand_id,
mfp.demand_date, mfp.transaction_id, TRUNC (GREATEST (ms.promised_date, SYSDATE))

select * from arw_app_dev.xxddk_fifo_pd_ti_data x where 1=1


and exists
(select 1 from arw_app_dev.xxddk_fifo_pd_ti_x_peg_data y
where y.inventory_item_id = x.inventory_item_id
and y.organization_id = x.organization_id)
order by inventory_item_id, organization_id, dmd, sup

You might also like