Select on a date and return cannot be null



  • I need the return of a date if it is "Null" in the BD to return another date or another given that it is not "Null".



  • Try 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 that, even if the field is null, something will return to you.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2