Stef
Stef

Reputation: 139

how to set NVL on SQL with TO_CHAR(MAX)

I trying to set a nvl() with the value OPEN on ->

        select to_char(max(CLOSE_DATE),'dd.mm.yyyy hh24:mi:ss') 

If it is closed is getting the date ('dd.mm.yyyy hh24:mi:ss') otherwise it should display OPEN

Any ideas, where I can put correctly the NVL()?

Solution:

        select nvl (to_char(max(CLOSE_DATE),'dd.mm.yyyy hh24:mi:ss'), 'OPEN')

Upvotes: 1

Views: 1656

Answers (1)

Littlefoot
Littlefoot

Reputation: 142968

This?

select decode(close_date, null, 'OPEN', 
                                to_char(close_date, 'dd.mm.yyyy hh24:mi:ss'
             ) result
from your_table

Or

select nvl(to_char(close_date, 'dd.mm.yyyy hh24:mi:ss'), 'OPEN') result
from your_table

Upvotes: 2

Related Questions