This Immortal
This Immortal

Reputation: 29

Set the same value to columns if column is null and another value if column is not null using just nvl, decode or coalesce in Oracle

I need write select script that checks if column is null then shows "is null" value, when column is not null then shows "is not null" value in output. But I should use only nvl, decode or coalesce functions. Using another functionalities is not allowed.

Upvotes: -1

Views: 62

Answers (1)

Littlefoot
Littlefoot

Reputation: 143133

Decode is quite simple:

select decode(column_name, null, 'is null',
                                 'is not null'
             ) as result
from your_table

I don't see why (or how) should NVL and coalesce be involved here, their purpose is different. Maybe you could use them, but - that would be unnecessarily complicated.

Upvotes: 0

Related Questions