Simple Question about sql [message #20177] |
Fri, 03 May 2002 16:04 |
shreya
Messages: 15 Registered: March 2001
|
Junior Member |
|
|
Hi,
My query is like this.
SELECT a.invoice_id,
a.amount,b.amount
FROM invoice@x1 a,
invoice@x2 b
WHERE a.invoice_id(+) = b.invoice_id
AND ABS(a.amount-b.amount) /
DECODE(a.amount,0,1,a.amount)
>= &tolerance
I am having a problem.
When tolerance=0, then it should be >tolerance.
When tolerance=1, then it should be >=tolerance.
When tolerance is between 0 and 1, either >tolerance or >=tolerance works.
If u know workaround for this solution, please let me know. I will be very thankful to u.
Regards,
Shashank.
|
|
|
Re: Simple Question about sql [message #20178 is a reply to message #20177] |
Fri, 03 May 2002 16:55 |
uma
Messages: 67 Registered: May 2001
|
Member |
|
|
You can use " if then else" by using a CASE statement.
Syntax is like this
(CASE WHEN (TOLERANCE=0) THEN CONDN1
ELSE (CASE WHEN TOLERANCE =1 THEN CONDN2
ELSE ..(SO ON)..... END) END)
I have not given the complete query for you but you can try by using the above syntax.
I hope it helps,
Thx
Uma
|
|
|
|
|