Logic of rewriting a Query!!! [message #289204] |
Thu, 20 December 2007 03:29  |
maggy_ashee
Messages: 70 Registered: May 2007
|
Member |
|
|
Hi all,
The below query is just a part of my Original Query,I am facing Performance issue in the Query.This query inturn will pop up a Java page and display the results.
Issue :
1. I need a logic wherein if the join1 returns NULL values then it should ignore the next join join2,if it returns a value then
it should go for the next join join2.(Hope this clear)
.
.
join1 and h.acc_no = nvl (ak.value,h.acc_no)
join2 and ak.att_code = 'CUST_N0'
join3 and ak.user = bk.user_id
.
.
Can someone help me in rewriting this Query
Appreciate your response!!!
|
|
|
|
|
Re: Logic of rewriting a Query!!! [message #289218 is a reply to message #289217] |
Thu, 20 December 2007 05:27   |
S.Rajaram
Messages: 1027 Registered: October 2006 Location: United Kingdom
|
Senior Member |
|
|
I will give you a very tiny example. I think this is what you are after
(a.col1 = b.col1
and b.col1 = c.col1
and c.col1 = d.col1)
or
(a.col1 = b.col1
and b.col1 = c.col1)
or
(a.col1 = b.col1)
The way it equates is get me the records which matches any of those conditions. Try to build your logic from there...
HTH
Regards
Raj
|
|
|
|
Re: Logic of rewriting a Query!!! [message #289346 is a reply to message #289248] |
Thu, 20 December 2007 19:49  |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
FROM h
LEFT JOIN (
SELECT ak.value
FROM ak
JOIN bk ON bk.user_id = ak.user
WHERE ak.att_code = 'CUST_N0'
) x ON x.value = h.acc_no
Warning: this type of query may produce performance problems if you are only selecting a few rows from a large table.
Ross Leishman
|
|
|