Hello,
I have created a query using unions that runs fine but runs slow. I was trying to speed this up and am thinking subqueries would solve the problem. I am having difficulty in turning these into subqueries. I've tried a few iterations but keep returning incorrect data sets duplicating data. Any help greatly appreciated.
select a.inci_id, a.appstate, a.district, a.category2, c.descriptn, a.csstatus, b.prop_id, b.propcode, b.propdesc
from lwmain a, prmain b, systab1 c
where a.inci_id = b.case_id (+)
and a.category2 = c.code_agcy (+)
and c.code_key = 'CAT2'
and b.propcode = '13'
union
select a.inci_id, a.appstate, a.district, a.category2, c.descriptn, a.csstatus, b.prop_id, b.propcode, b.propdesc
from lwmain a, prmain b, systab1 c
where a.inci_id = b.case_id (+)
and a.category2 = c.code_agcy (+)
and c.code_key = 'CAT2'
and b.propcode = '77'
and b.propdesc LIKE '%CARTR%'
union
select a.inci_id, a.appstate, a.district, a.category2, c.descriptn, a.csstatus, b.prop_id, b.propcode, b.propdesc
from lwmain a, prmain b, systab1 c
where a.inci_id = b.case_id (+)
and a.category2 = c.code_agcy (+)
and c.code_key = 'CAT2'
and b.propcode = '77'
and b.propdesc LIKE '%PROJECT%'
I have created a query using unions that runs fine but runs slow. I was trying to speed this up and am thinking subqueries would solve the problem. I am having difficulty in turning these into subqueries. I've tried a few iterations but keep returning incorrect data sets duplicating data. Any help greatly appreciated.
select a.inci_id, a.appstate, a.district, a.category2, c.descriptn, a.csstatus, b.prop_id, b.propcode, b.propdesc
from lwmain a, prmain b, systab1 c
where a.inci_id = b.case_id (+)
and a.category2 = c.code_agcy (+)
and c.code_key = 'CAT2'
and b.propcode = '13'
union
select a.inci_id, a.appstate, a.district, a.category2, c.descriptn, a.csstatus, b.prop_id, b.propcode, b.propdesc
from lwmain a, prmain b, systab1 c
where a.inci_id = b.case_id (+)
and a.category2 = c.code_agcy (+)
and c.code_key = 'CAT2'
and b.propcode = '77'
and b.propdesc LIKE '%CARTR%'
union
select a.inci_id, a.appstate, a.district, a.category2, c.descriptn, a.csstatus, b.prop_id, b.propcode, b.propdesc
from lwmain a, prmain b, systab1 c
where a.inci_id = b.case_id (+)
and a.category2 = c.code_agcy (+)
and c.code_key = 'CAT2'
and b.propcode = '77'
and b.propdesc LIKE '%PROJECT%'