Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: case statement for oracle ?
Try
select decode(val,0,NULL,val) from tab;
In article <376E053B.8B2006FF_at_mpimp-golm.mpg.de>,
Sebastian Kloska <kloska_at_mpimp-golm.mpg.de> wrote:
> Hi,
>
> Is their anything like a case statement in the form
>
> CASE
> WHEN val=0 then null
> ELSE val
> END
>
> for Oracle. My SQL books claim that 'CASE' is ANSI SQL but
> Oracle doesn't seem to support is. The only way to somehow
> emulate it seems to be a union in the form
>
> SELECT val from tab where val<>0
> UNION
> SELECT null from tab where val=0
>
> This would become rather ugly in my case because tab is a rather
> complex
> subquery which I would have to state twice.
>
> Thank you for any help...
>
> Sebastian
>
> --
> ======================================================================
> Dr. Sebastian Kloska; Max-Planck Institut für Mol. Pflanzenphysiologie
> Karl Liebknecht Straße 25; 14476 Golm; Tel: (+49 030) 84131542
> * NEW MAIL ADDRESS * mailto:kloska_at_mpimp-golm.mpg.de
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Mon Jun 21 1999 - 09:17:25 CDT