Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: EASY ? Case statement
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 guyReceived on Thu Nov 02 2000 - 04:59:59 CST
![]() |
![]() |