Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

DECODE QUESTION

BMax007Aug 20 2009 — edited Aug 20 2009
I 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?
This post has been answered by 666352 on Aug 20 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 17 2009
Added on Aug 20 2009
7 comments
422 views