Home > Archive > Other Oracle database topics > September 2005 > How can I re-write this piece of code for better performance!?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How can I re-write this piece of code for better performance!?
lou_nyc

2005-09-30, 8:23 pm

select p.d_insp_date,
p.d_dam_date_by
,b.stat
,NVL(a.cnt,0) CNT
from
(select aa.dam_insp_date,
a.dam_insp_by,
bb.stat
from (select distinct trunc(gc.dam_insp_date) gc.dam_insp_date,
gc.dam_insp_by
from damages gd, gate_con gc
where gd.g_id = gc.g_id
) aa,
(select *
from (select 'MAJOR' STATUS from dual
union all
select 'MINOR' STATUS from dual
union all
select 'TOTAL' STATUS from dual
)
) bb
)b,
((SELECT dam_insp_date,
dam_insp_by,
Stat,
cnt
FROM (select trunc(c.dam_insp_date) dam_insp_date,
c.dam_insp_by,
'MAJOR' STATUS,
count(distinct c.g_id) cnt
from gate_cont c,
damages d
where c.gate_id = d.gate_id and
d.damage_type_code = 'A'
group by
trunc(c. damage_inspection_da
te),c. damage_inspection_by

UNION ALL
select trunc(g. damage_inspection_da
te)
damage_inspection_da
te,
g. damage_inspection_by
,
'MINOR' STATUS,
count(distinct g.gate_id) cnt
from gate_containers g,
damages z
where g.gate_id = z.gate_id and
z.damage_type_code = 'F'
group by
trunc(g. damage_inspection_da
te),g. damage_inspection_by

UNION ALL
select trunc(ap.d_insp_date) damage_inspection_da
te,
ap.d_dam_date_by,
'TOTAL' STATUS,
count(distinct ab.gate_id) cnt
from gate_containers ab,
damages ac
where ab.gate_id = ac.gate_id
group by trunc(ap.d_insp_date),ap.d_dam_date_by
)
group by damage_inspection_da
te, damage_inspection_by
,
status, cnt
)
) a
where p.d_dam_date_by = a. damage_inspection_by
(+)
and p.d_insp_date = a. damage_inspection_da
te(+)
and b.status = a.status(+);

lou_nyc

2005-09-30, 8:23 pm

Please disregard this post... please look at the newer one!

lou_nyc

2005-09-30, 8:23 pm

this is the most updated post..

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com