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

Home -> Community -> Usenet -> c.d.o.tools -> Re: EASY ? Case statement

Re: EASY ? Case statement

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Thu, 02 Nov 2000 18:59:59 +0800
Message-ID: <3A01492F.1903@yahoo.com>

TurkBear wrote:
>
> There is no 'case' statement as such in SqlPlus use:
>
> Select DECODE(ename,'SCOTT','IIII','CCCC') as test,
> ename from emp;
>
> Check out the docs on the DECODE function for a full explanation on what it can
> do...
>
> "Olivier Villeneuve" <olivier.villeneuve_at_fra.sas.com> wrote:
>
> >Hi There,
> >
> >What is the right syntax to do this :
> >
> > select case ename when ('SCOTT') then 'IIII' else 'CCCC' end as test ,
> > ename from emp;
> >
> >This code returns an error ORA-00923
> >
> >Best Regards,
> >Olivier.
> >
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 80,000 Newsgroups - 16 Different Servers! =-----

8.1.6 and above has "case" support..

eg

SELECT AVG(CASE WHEN e.sal > 2000 THEN e.sal ELSE 2000 END) from emp e;

HTH

-- 
===========================================
Connor McDonald
http://www.oracledba.co.uk (mirrored at
http://www.oradba.freeserve.co.uk)

"Early to bed and early to rise, 
 makes a man healthy, wealthy and wise." - some dead guy
Received on Thu Nov 02 2000 - 04:59:59 CST

Original text of this message

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