DECODE-How to include a virtual 'AND' or NOT EQUAL TO [message #371087] |
Thu, 24 August 2000 13:28 |
Chris
Messages: 128 Registered: November 1998
|
Senior Member |
|
|
Hi everyone,
Could someone tell me if it's possible to use the word 'AND' or <> or something like them in a DECODE statement.
Ex: DECODE(A.VALUE, 2 AND B.VALUE <> 3, C.VALUE, 2 'AND' B.VALUE = 3, D.VALUE, NULL) AS HOPE_THIS_WORKS
Here's the statement I'm dealing with now:
SUM(DECODE(A.TYPE, 2, (ROUND(SUM((A.INV_TOTAL-A.TAX_TOTAL)* .07),3)), NULL)) "BILLING_INVOICE(GST)",
Essentially I want to say if A.TYPE = 2 AND B.CODE <> 3 then calculate the GST, elseif A.TYPE = 2 AND B.CODE = 3 then NULL) AS HOPE_THIS_WORKS
Any help would be greatly appreciated.
|
|
|
Re: DECODE-How to include a virtual 'AND' or NOT EQUAL TO [message #371088 is a reply to message #371087] |
Thu, 24 August 2000 14:05 |
JOHN
Messages: 182 Registered: April 1998
|
Senior Member |
|
|
You have me a little confused - how many values are we checking a,b,c,d = 4? You can use nested decodes if value d depends on resultant values of c and c depends on resultant value of b which is based on the resultant value of a.
decode(a.type,2,decode(b.value,3,null,(ROUND(SUM((A.INV_TOTAL-A.TAX_TOTAL)* .07),3)),null)
I hope that I am not confusing you.
If you can give me more specifics, maybe I can do a better job of contructing the decodes for you.
John
|
|
|
|
|