DECODE QUESTION
BMax007Aug 20 2009 — edited Aug 20 2009I have 4 columns that I want to test for the existance of a value greater than 0 in order of last to first and then return the value of the first column found that has a value > 0.
I have columns discount_2,discount_1,supplier_2 and supplier_1. When I try to decode these columns it will return a value when there is a value in discount_1 or 2 but not when there is not a value in discount_1 or 2 and there is a value in supplier_1 or 2.
My decode statement looks like:
DECODE(DISCOUNT_2,NULL,DISCOUNT_1,
DECODE(DISCOUNT_1,NULL,SUPPLIER_2),SUPPLIER_1) AS "ORIG_COST"
Will the decode work in this example or would CASE work better and what would it look like?