decode return result for empty

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Fri, 30 Nov 2007 10:25 am

I'm here in less than 1 day hahahahaha, aí people doubt is the following have the table: DTEXCLUSAO ai I wanted to use the decode for when the date fo (is null) he would return the word \"Empty\", when is the date he returned another phrase type: \"active user\".
att ´
carlos12
Location: rio

Poston Fri, 30 Nov 2007 10:38 am

Oops, and Carlos, baby??

There follows an example.
Code: Select all
SQL> SELECT nome,
  2         data,
  3         decode (data, null, 'Vazio', 'Usuário Ativo') situacao
  4    FROM mens_erro2
  5  /

NOME                 DATA      SITUACAO
-------------------- --------- -------------
MARIA                          Vazio
JOSE                 30-NOV-07 Usuário Ativo


[]'s
Tineks
Location: Araraquara - SP

Cristiano (Tineks)
Araraquara - SP

Poston Fri, 30 Nov 2007 10:47 am

I saw the topic that Carlos ' wanted ' to use the decode, but the question is, in this case could not use the NVL2? He can sr used with dates or only for string?
bassman
Location: Portão - RS

Poston Fri, 30 Nov 2007 10:52 am

The nvl2 can be used Yes, he just can't be used with field of type Long, the result would be the same.

Code: Select all
SQL> SELECT nome,
  2         data,
  3         decode (data, null, 'Vazio', 'Usuário Ativo') situacao ,
  4         nvl2(data,'Usuário Ativo','Vazio') situacao2
  5      FROM mens_erro2
  6  /

NOME                 DATA      SITUACAO      SITUACAO2
-------------------- --------- ------------- -------------
MARIA                          Vazio         Vazio
JOSE                 30-NOV-07 Usuário Ativo Usuário Ativo


[]'s
Tineks
Location: Araraquara - SP

Cristiano (Tineks)
Araraquara - SP

Poston Fri, 30 Nov 2007 10:55 am

Thank you very much for the clarification!!
Actually the forum is of great value!!
bassman
Location: Portão - RS

Poston Fri, 30 Nov 2007 11:12 am

More once Cristiano valeu by force my friend!
carlos12
Location: rio



Return to SQL

Who is online

Users browsing this forum: No registered users and 5 guests