What's up friends, I have that question, what is the function/purpose of a DECODE ?
SELECT PART_NO, PROD_VERSION, TO_CHAR(ORIGINAL_START_DATE, 'MM-DD-YYYY HH:MI:SS AM'), DECODE(OWNER, 'PRODUCTION_1', 'PRODUCTION_2', 'PRODUCTION_3', 'PRODUCTION_4', 'PRODUCTION_5', 'PRODUCTION_6', OWNER) LOTTEST
I understand that it is some kind of IF-THEN-ELSE statement , but I can't figure out how.
One thing learned from experience is that the way you lay out your code can provide you with information, in this case:
it's a single-line query, but if you look at it with this indentation, you'll see that it's a bit clearer:
It will take the value of
OWNER
and if its value is'PRODUCTION_1'
it will convert it to'PRODUCTION_2'
, if it is'PRODUCTION_3'
it will convert it to'PRODUCTION_4'
, if it is'PRODUCTION_5'
it will convert it to'PRODUCTION_6'
and in case it is neither of those, it will leave it with its original value.