user3172075
user3172075

Reputation: 133

Using oracle decode

I have read an article regarding rename data from oracle column. I follow one of the query posted, but when I try on my own. I just only get NULL values. Please help me, what's wrong in my DECODE QUERY.

The original data of status column is 'no answer' and 'answer'

Thanks.

Here's my query

select call_time, decode(status, 'no answer', 'hey', 'answer', 'yes'), channel
FROM APP_ACCOUNT.CC_CALL;

And the output of this is:

call_time   decode(status, 'no answer', 'hey', 'answer', 'yes')        CHANNEL
10/22/2013  NULL                                                       DAHDI/i1/
11/05/2013  NULL                                                       DAHDI/i2/

Instead of:

call_time   decode(status, 'no answer', 'hey', 'answer', 'yes')        CHANNEL
10/22/2013  yes                                                    DAHDI/i1/
11/05/2013  hey                                                    DAHDI/i2/

Upvotes: 0

Views: 157

Answers (1)

sotondolphin
sotondolphin

Reputation: 223

When use decode, you should always supply with a default value decode(value from db, matching 1, alternative value1, matching2, alternative value,...matching n, alternative value n, DEFAULT VALUE)

so that you won't have null returned if all the matches are failed

Upvotes: 1

Related Questions