Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

query rewrite

elmasduroOct 13 2009 — edited Oct 13 2009
hi all, i am looking for a way to rewrite this query. i am accessing the same table 3 times and this could hurt performance when the table grow in size.
please help. how can i write this query in a way that i dont have to access the same table like 3 times

SELECT
lid,
amt,
date
FROM table1
WHERE type = '2'

UNION ALL

SELECT
lid,
amt * -23 as amt,
date
FROM
( SELECT *
FROM table1
WHERE type = '0'
AND lid NOT IN (SELECT lid
FROM table1
WHERE type = '2')
)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 10 2009
Added on Oct 13 2009
4 comments
355 views