Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Generating Binary Column
Here are two ways:
select X, case when X >= 5 THEN 1 ELSE 0 END as TheThing from TheTable
select X, decode( sign(X), -1, 0, 1 ) as TheThing from TheTable
nevergiveup_at_my-deja.com wrote:
> Hello,
>
> I have Table T with Column X.
> I want to generate Column Y in the same table, or in the new view V.
>
> I want Y to have the value of 1 if X >= 5, and 0 if otherwise.
>
> How would I do this?
> I have been looking into Decode, and it doesn't seem to do it.
> I think Decode only works for text matching.
>
> Thank you,
>
> Gingko
>
> Sent via Deja.com
> http://www.deja.com/
Received on Thu Feb 15 2001 - 17:52:16 CST