How to Avoid repeating of query(rewrite query)
743620Apr 24 2012 — edited Apr 25 2012Have the follwoing select statement in cursor. How can i avoid repeating the same select statement but with different columns n the where clause conditions.
for cur1 in (SELECT d.ID,
name
type,
code
FROM tableA ,c
tableB d
WHERE c.id = d.id
AND d.vin_id IN
-- select statement
(SELECT b.id
FROM tableA a,
TableB b
WHERE a.id = b.id
GROUP BY b.id,
b.code
HAVING COUNT(1) = 1
)
AND d.code IN
--same select stmt used before with diff col
(SELECT b.id
FROM tableA a,
TableB b
WHERE a.id = b.id
GROUP BY b.id,
b.code
HAVING COUNT(1) = 1
))