Select on a date and return cannot be null

Asked

Viewed 68 times

0

I need the return of a date, if it is "Null" in the BD return another date or other data that is not "Null".

3 answers

1

Try it like this:

select case
         when campo_que_pode_estar_null is null then 'valor retornado se estiver null'
       else
         campo_que_pode_estar_null
       end 
from tabela

With this, even if the field is null, it will return something.

0


Attribute the IS NOT NULL as it will filter all values that are not NULL.

SELECT * FROM Table WHERE DataInicio IS NOT NULL

-1

I forgot to mention that the database was Firebird.

But I found a solution, I used the coalesce('nomedacoluna',0 ou'') as 'nomedacoluna'

  • Luis edit your question with this detail, do not use the answer field to correct yourself. I advise you to delete this answer and edit your question

Browser other questions tagged

You are not signed in. Login or sign up in order to post.