Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to select 0 as null

Re: How to select 0 as null

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Fri, 23 Jul 1999 14:44:53 GMT
Message-ID: <37a77fbe.100930670@newshost.us.oracle.com>


A copy of this was sent to "Kim Bundgaard" <KIB_at_kmd.dk> (if that email address didn't require changing) On 23 Jul 1999 14:33:53 GMT, you wrote:

>I'm not so familar with Oracle - so excuse for a potentially "not so
>intelligent" question.
>
>How do I select a zero value as null, and all other values with is correct
>value. I want my resultset to have null instead of zero for the row where
>my column value is zero, and all other value should have their correct
>value (ie. 10, 125 and so on).
>
>I can do it with som combination of union all and where clause, but that
>seems a little bit nasty.
>

select decode( column_name, 0, null, column_name )   from t
/

will do it. that says "if column_name = 0 return null else return column_name"

>Any suggestion would be appreciated.
>
>/Kim Bundgaard

--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Fri Jul 23 1999 - 09:44:53 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US