query rewrite
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')
)