Commit 2538ad59 authored by prane's avatar prane

added spaces in sql

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@213515 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 441df9ce
select item_code,due_date, round(sum(demand)+ fn_get_sampleqty(item_code ,'@sitecode@' ),0) demand , sum(supply) supply, sum(stock_qty) stock_qty, select item_code,due_date, round(sum(demand)+ fn_get_sampleqty(item_code ,'@sitecode@' ),0) demand , sum(supply) supply, sum(stock_qty) stock_qty,
sum(oth_supply) oth_supply, sum(pending_po) pending_po ,sum(pending_do) pending_do, sum(pending_indent) pending_indent, sum(pending_dr) pending_dr ,tran_id,tran_ser ,site_code sum(oth_supply) oth_supply, sum(pending_po) pending_po ,sum(pending_do) pending_do, sum(pending_indent) pending_indent, sum(pending_dr) pending_dr ,tran_id,tran_ser ,site_code
from from
( (
select item.item_code, inv_dem_supp.due_date , sum(inv_dem_supp.demand_QTY) demand , sum(inv_dem_supp.SUPPLY_QTY) supply, select item.item_code, inv_dem_supp.due_date , sum(inv_dem_supp.demand_QTY) demand , sum(inv_dem_supp.SUPPLY_QTY) supply,
0 stock_qty,0 oth_supply,0 pending_po, 0 pending_do, 0 stock_qty,0 oth_supply,0 pending_po, 0 pending_do,
sum(case when inv_dem_supp.REF_SER = 'IND' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_indent, sum(case when inv_dem_supp.REF_SER = 'IND' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_indent,
0 pending_dr, inv_dem_supp.ref_id as tran_id, inv_dem_supp.ref_ser as tran_ser, inv_dem_supp.site_code 0 pending_dr, inv_dem_supp.ref_id as tran_id, inv_dem_supp.ref_ser as tran_ser, inv_dem_supp.site_code
from inv_dem_supp, item from inv_dem_supp, item
where where ( inv_dem_supp.item_code = item.item_code )
( inv_dem_supp.item_code = item.item_code )
and ( inv_dem_supp.site_code in ('@sitecode@') ) and ( inv_dem_supp.site_code in ('@sitecode@') )
AND ( item.item_code__plan = '@itemcode@') AND ( item.item_code__plan = '@itemcode@')
AND ( inv_dem_supp.REF_SER in ('I-DEM','D-DEM','S-DEM','S-FST','IND') ) AND ( inv_dem_supp.REF_SER in ('I-DEM','D-DEM','S-DEM','S-FST','IND') )
AND ( inv_dem_supp.REF_SER not in ('P-ORD','D-ORDI','D-ORDR','W-ORD','W-BIL','STK') ) AND ( inv_dem_supp.REF_SER not in ('P-ORD','D-ORDI','D-ORDR','W-ORD','W-BIL','STK') )
and ( inv_dem_supp.due_date >= to_date('@fromdate@')) and ( inv_dem_supp.due_date >= to_date('@fromdate@'))
AND ( inv_dem_supp.due_date <= to_date('@todate@')) AND ( inv_dem_supp.due_date <= to_date('@todate@'))
AND trim(nvl((select si.mfg_type from siteitem si where si.site_code = inv_dem_supp.site_code and si.item_code = item.item_code ),' ')) not in ('O','D') AND trim(nvl((select si.mfg_type from siteitem si where si.site_code = inv_dem_supp.site_code and si.item_code = item.item_code ),' ')) not in ('O','D')
group by item.item_code, inv_dem_supp.due_date,inv_dem_supp.ref_id, inv_dem_supp.ref_ser , inv_dem_supp.site_code group by item.item_code, inv_dem_supp.due_date,inv_dem_supp.ref_id, inv_dem_supp.ref_ser , inv_dem_supp.site_code
UNION ALL UNION ALL
select item.item_code, case when inv_dem_supp.REF_SER in ('W-ORD','W-BIL') then to_date('@fromdate@') else inv_dem_supp.due_date end as due_date, select item.item_code, case when inv_dem_supp.REF_SER in ('W-ORD','W-BIL') then to_date('@fromdate@') else inv_dem_supp.due_date end as due_date,
sum(inv_dem_supp.demand_QTY) demand , sum(inv_dem_supp.demand_QTY) demand ,
sum(inv_dem_supp.SUPPLY_QTY) supply, sum(inv_dem_supp.SUPPLY_QTY) supply,
...@@ -30,18 +29,18 @@ sum(case when inv_dem_supp.REF_SER = 'P-ORD' then inv_dem_supp.SUPPLY_QTY else ...@@ -30,18 +29,18 @@ sum(case when inv_dem_supp.REF_SER = 'P-ORD' then inv_dem_supp.SUPPLY_QTY else
sum(case when inv_dem_supp.REF_SER = 'D-ORDI' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_do, sum(case when inv_dem_supp.REF_SER = 'D-ORDI' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_do,
0 pending_indent, 0 pending_indent,
sum(case when inv_dem_supp.REF_SER = 'D-ORDR' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_dr, sum(case when inv_dem_supp.REF_SER = 'D-ORDR' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_dr,
inv_dem_supp.ref_id as tran_id, inv_dem_supp.ref_ser as tran_ser, inv_dem_supp.site_code inv_dem_supp.ref_id as tran_id, inv_dem_supp.ref_ser as tran_ser, inv_dem_supp.site_code
from inv_dem_supp, item from inv_dem_supp, item
where ( inv_dem_supp.item_code = item.item_code ) where ( inv_dem_supp.item_code = item.item_code )
and ( inv_dem_supp.site_code in ('@sitecode@') ) and ( inv_dem_supp.site_code in ('@sitecode@') )
AND ( item.item_code__plan = '@itemcode@') AND ( item.item_code__plan = '@itemcode@')
AND ( inv_dem_supp.REF_SER in ('P-ORD','D-ORDI','D-ORDR','W-ORD','W-BIL') ) AND ( inv_dem_supp.REF_SER in ('P-ORD','D-ORDI','D-ORDR','W-ORD','W-BIL') )
AND ( inv_dem_supp.due_date <= to_date('@todate@')) AND ( inv_dem_supp.due_date <= to_date('@todate@'))
group by item.item_code, case when inv_dem_supp.REF_SER in ('W-ORD','W-BIL') then to_date('@fromdate@') else inv_dem_supp.due_date end, group by item.item_code, case when inv_dem_supp.REF_SER in ('W-ORD','W-BIL') then to_date('@fromdate@') else inv_dem_supp.due_date end,
inv_dem_supp.ref_id, inv_dem_supp.ref_ser, inv_dem_supp.site_code inv_dem_supp.ref_id, inv_dem_supp.ref_ser, inv_dem_supp.site_code
union all UNION ALL
select item.item_code, FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date, select item.item_code, FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,
0 demand , 0 demand ,
sum(inv_dem_supp.SUPPLY_QTY) supply, sum(inv_dem_supp.SUPPLY_QTY) supply,
...@@ -51,32 +50,32 @@ sum(inv_dem_supp.SUPPLY_QTY) stock_qty, ...@@ -51,32 +50,32 @@ sum(inv_dem_supp.SUPPLY_QTY) stock_qty,
0 pending_do, 0 pending_do,
0 pending_indent, 0 pending_indent,
0 pending_dr, 0 pending_dr,
inv_dem_supp.ref_id as tran_id, inv_dem_supp.ref_ser as tran_ser, inv_dem_supp.site_code inv_dem_supp.ref_id as tran_id, inv_dem_supp.ref_ser as tran_ser, inv_dem_supp.site_code
from inv_dem_supp, item from inv_dem_supp, item
where ( inv_dem_supp.item_code = item.item_code ) where ( inv_dem_supp.item_code = item.item_code )
and ( inv_dem_supp.site_code in ('@sitecode@') ) and ( inv_dem_supp.site_code in ('@sitecode@') )
AND ( item.item_code__plan = '@itemcode@') AND ( item.item_code__plan = '@itemcode@')
AND ( inv_dem_supp.REF_SER in ('STK') ) AND ( inv_dem_supp.REF_SER in ('STK') )
group by item.item_code, FN_MRP_DUEDATE(to_date('@fromdate@')), inv_dem_supp.ref_id, inv_dem_supp.ref_ser, inv_dem_supp.site_code GROUP BY item.item_code, FN_MRP_DUEDATE(to_date('@fromdate@')), inv_dem_supp.ref_id, inv_dem_supp.ref_ser, inv_dem_supp.site_code
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date, 0 as demand, SELECT item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date, 0 as demand,
sum(invtrace.eff_qty) *-1 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr, sum(invtrace.eff_qty) *-1 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr,
invtrace.ref_id||'@'||invtrace.ref_line as tran_id, invtrace.ref_ser as tran_ser, invtrace.site_code invtrace.ref_id||'@'||invtrace.ref_line as tran_id, invtrace.ref_ser as tran_ser, invtrace.site_code
FROM invtrace, item, location, invstat FROM invtrace, item, location, invstat
WHERE ( invtrace.item_code = item.item_code ) and WHERE ( invtrace.item_code = item.item_code ) and
( location.loc_code = invtrace.loc_code) and ( location.loc_code = invtrace.loc_code) and
( invstat.inv_stat = location.inv_stat) and ( invstat.inv_stat = location.inv_stat) and
( invstat.stat_type <> 'S' ) and ( invstat.stat_type <> 'S' ) and
NVL( invstat.plan_prod,'N') = 'Y' and NVL( invstat.plan_prod,'N') = 'Y' and
( invtrace.site_code in ('@sitecode@') ) AND ( invtrace.site_code in ('@sitecode@') ) AND
( item.item_code__plan = '@itemcode@') AND ( item.item_code__plan = '@itemcode@') AND
( invtrace.tran_date >= to_date('@fromdate@')) and ( invtrace.tran_date >= to_date('@fromdate@')) and
( invtrace.tran_date <= to_date('@rundate@')) and ( invtrace.tran_date <= to_date('@rundate@')) and
( invtrace.ref_ser in ('D-ISS','S-DSP') ) and ( invtrace.ref_ser in ('D-ISS','S-DSP') ) and
trim(nvl((select si.mfg_type from siteitem si where si.site_code = invtrace.site_code and si.item_code = invtrace.item_code ),' ')) not in ('O','D') trim(nvl((select si.mfg_type from siteitem si where si.site_code = invtrace.site_code and si.item_code = invtrace.item_code ),' ')) not in ('O','D')
Group By item.item_code__plan, invtrace.ref_id||'@'||invtrace.ref_line, invtrace.ref_ser, invtrace.site_code GROUP BY item.item_code__plan, invtrace.ref_id||'@'||invtrace.ref_line, invtrace.ref_ser, invtrace.site_code
) )
group by item_code,due_date,tran_id,tran_ser,site_code GROUP BY item_code,due_date,tran_id,tran_ser,site_code
having sum(demand) <> 0 or sum(supply) <> 0 HAVING sum(demand) <> 0 or sum(supply) <> 0
select item_code,due_date, round(sum(demand)+ fn_get_sampleqty(item_code ,'@sitecode@' ),0) demand , sum(supply) supply, sum(stock_qty) stock_qty, select item_code,due_date, round(sum(demand)+ fn_get_sampleqty(item_code ,'@sitecode@' ),0) demand , sum(supply) supply, sum(stock_qty) stock_qty,
sum(oth_supply) oth_supply, sum(pending_po) pending_po ,sum(pending_do) pending_do, sum(pending_indent) pending_indent, sum(pending_dr) pending_dr sum(oth_supply) oth_supply, sum(pending_po) pending_po ,sum(pending_do) pending_do, sum(pending_indent) pending_indent, sum(pending_dr) pending_dr
from from
( (
select item.item_code, inv_dem_supp.due_date , select item.item_code, inv_dem_supp.due_date ,
sum(inv_dem_supp.demand_QTY) demand , sum(inv_dem_supp.demand_QTY) demand ,
sum(inv_dem_supp.SUPPLY_QTY) supply, sum(inv_dem_supp.SUPPLY_QTY) supply,
...@@ -11,40 +11,39 @@ sum(inv_dem_supp.SUPPLY_QTY) supply, ...@@ -11,40 +11,39 @@ sum(inv_dem_supp.SUPPLY_QTY) supply,
0 pending_po, 0 pending_po,
0 pending_do, 0 pending_do,
sum(case when inv_dem_supp.REF_SER = 'IND' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_indent, sum(case when inv_dem_supp.REF_SER = 'IND' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_indent,
0 pending_dr 0 pending_dr
from inv_dem_supp, item from inv_dem_supp, item
where where ( inv_dem_supp.item_code = item.item_code )
( inv_dem_supp.item_code = item.item_code )
and ( inv_dem_supp.site_code in ('@sitecode@') ) and ( inv_dem_supp.site_code in ('@sitecode@') )
AND ( item.item_code__plan = '@itemcode@') AND ( item.item_code__plan = '@itemcode@')
AND ( inv_dem_supp.REF_SER in ('I-DEM','D-DEM','S-DEM','S-FST','IND') ) AND ( inv_dem_supp.REF_SER in ('I-DEM','D-DEM','S-DEM','S-FST','IND') )
AND ( inv_dem_supp.REF_SER not in ('P-ORD','D-ORDI','D-ORDR','W-ORD','W-BIL','STK') ) AND ( inv_dem_supp.REF_SER not in ('P-ORD','D-ORDI','D-ORDR','W-ORD','W-BIL','STK') )
and ( inv_dem_supp.due_date >= to_date('@fromdate@')) and ( inv_dem_supp.due_date >= to_date('@fromdate@'))
AND ( inv_dem_supp.due_date <= to_date('@todate@')) AND ( inv_dem_supp.due_date <= to_date('@todate@'))
AND trim(nvl((select si.mfg_type from siteitem si where si.site_code = inv_dem_supp.site_code and si.item_code = item.item_code ),' ')) not in ('O','D') AND trim(nvl((select si.mfg_type from siteitem si where si.site_code = inv_dem_supp.site_code and si.item_code = item.item_code ),' ')) not in ('O','D')
group by item.item_code, inv_dem_supp.due_date group by item.item_code, inv_dem_supp.due_date
UNION ALL UNION ALL
select item.item_code, case when inv_dem_supp.REF_SER in ('W-ORD','W-BIL') then to_date('@fromdate@') else inv_dem_supp.due_date end as due_date, select item.item_code, case when inv_dem_supp.REF_SER in ('W-ORD','W-BIL') then to_date('@fromdate@') else inv_dem_supp.due_date end as due_date,
sum(inv_dem_supp.demand_QTY) demand , sum(inv_dem_supp.demand_QTY) demand ,
sum(inv_dem_supp.SUPPLY_QTY) supply, sum(inv_dem_supp.SUPPLY_QTY) supply,
0 stock_qty, 0 stock_qty,
0 oth_supply, 0 oth_supply,
sum(case when inv_dem_supp.REF_SER = 'P-ORD' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_po, sum(case when inv_dem_supp.REF_SER = 'P-ORD' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_po,
sum(case when inv_dem_supp.REF_SER = 'D-ORDI' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_do, sum(case when inv_dem_supp.REF_SER = 'D-ORDI' then inv_dem_supp.demand_QTY else 0 end) pending_do,
0 pending_indent, 0 pending_indent,
sum(case when inv_dem_supp.REF_SER = 'D-ORDR' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_dr sum(case when inv_dem_supp.REF_SER = 'D-ORDR' then inv_dem_supp.SUPPLY_QTY else 0 end) pending_dr
from inv_dem_supp, item from inv_dem_supp, item
where ( inv_dem_supp.item_code = item.item_code ) where ( inv_dem_supp.item_code = item.item_code )
and ( inv_dem_supp.site_code in ('@sitecode@') ) and ( inv_dem_supp.site_code in ('@sitecode@') )
AND ( item.item_code__plan = '@itemcode@') AND ( item.item_code__plan = '@itemcode@')
AND ( inv_dem_supp.REF_SER in ('P-ORD','D-ORDI','D-ORDR','W-ORD','W-BIL') ) AND ( inv_dem_supp.REF_SER in ('P-ORD','D-ORDI','D-ORDR','W-ORD','W-BIL') )
AND ( inv_dem_supp.due_date <= to_date('@todate@')) AND ( inv_dem_supp.due_date <= to_date('@todate@'))
group by item.item_code, case when inv_dem_supp.REF_SER in ('W-ORD','W-BIL') then to_date('@fromdate@') else inv_dem_supp.due_date end group by item.item_code, case when inv_dem_supp.REF_SER in ('W-ORD','W-BIL') then to_date('@fromdate@') else inv_dem_supp.due_date end
union all UNION ALL
select item.item_code, FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date, select item.item_code, FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,
0 demand , 0 demand ,
sum(inv_dem_supp.SUPPLY_QTY) supply, sum(inv_dem_supp.SUPPLY_QTY) supply,
...@@ -53,19 +52,19 @@ sum(inv_dem_supp.SUPPLY_QTY) stock_qty, ...@@ -53,19 +52,19 @@ sum(inv_dem_supp.SUPPLY_QTY) stock_qty,
0 pending_po, 0 pending_po,
0 pending_do, 0 pending_do,
0 pending_indent, 0 pending_indent,
0 pending_dr 0 pending_dr
from inv_dem_supp, item FROM inv_dem_supp, item
where ( inv_dem_supp.item_code = item.item_code ) WHERE ( inv_dem_supp.item_code = item.item_code )
and ( inv_dem_supp.site_code in ('@sitecode@') ) AND ( inv_dem_supp.site_code in ('@sitecode@') )
AND ( item.item_code__plan = '@itemcode@') AND ( item.item_code__plan = '@itemcode@')
AND ( inv_dem_supp.REF_SER in ('STK') ) AND ( inv_dem_supp.REF_SER in ('STK') )
group by item.item_code, FN_MRP_DUEDATE(to_date('@fromdate@')) GROUP BY item.item_code, FN_MRP_DUEDATE(to_date('@fromdate@'))
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date, 0 as demand, SELECT item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date, 0 as demand,
sum(invtrace.eff_qty) *-1 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr sum(invtrace.eff_qty) *-1 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM invtrace, item, location, invstat FROM invtrace, item, location, invstat
WHERE ( invtrace.item_code = item.item_code ) and WHERE ( invtrace.item_code = item.item_code ) and
( location.loc_code = invtrace.loc_code) and ( location.loc_code = invtrace.loc_code) and
( invstat.inv_stat = location.inv_stat) and ( invstat.inv_stat = location.inv_stat) and
...@@ -76,9 +75,9 @@ SELECT item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) ...@@ -76,9 +75,9 @@ SELECT item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@'))
( invtrace.tran_date >= to_date('@fromdate@')) and ( invtrace.tran_date >= to_date('@fromdate@')) and
( invtrace.tran_date <= to_date('@rundate@')) and ( invtrace.tran_date <= to_date('@rundate@')) and
( invtrace.ref_ser in ('D-ISS','S-DSP') ) and ( invtrace.ref_ser in ('D-ISS','S-DSP') ) and
trim(nvl((select si.mfg_type from siteitem si where si.site_code = invtrace.site_code and si.item_code = invtrace.item_code ),' ')) not in ('O','D') trim(nvl((select si.mfg_type from siteitem si where si.site_code = invtrace.site_code and si.item_code = invtrace.item_code ),' ')) not in ('O','D')
Group By item.item_code__plan,invtrace.tran_date GROUP BY item.item_code__plan,invtrace.tran_date
) )
group by item_code,due_date GROUP BY item_code,due_date
having sum(demand) <> 0 or sum(supply) <> 0 HAVING sum(demand) <> 0 or sum(supply) <> 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment