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

50 views Asked by At

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.

1

There are 1 answers

1
Littlefoot On

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.