Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: EASY ? Case statement
On Wed, 08 Nov 2000 07:16:47 GMT, Marc Billiet <someone.overthere_at_living_in.be> wrote:
>But unfortunately not in pl/sql...
>
>Marc
>
>>>>>>>>>>>>>>>>>>> Oorspronkelijk bericht <<<<<<<<<<<<<<<<<<
>
>Op 2000-11-02, 11:59:59, schreef Connor McDonald
><connor_mcdonald_at_yahoo.com> over het thema Re: EASY ? Case statement:
>
>> 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
Use :
SELECT AVG(GREATEST(2000, e.sal)) from emp e;
or
SELECT AVG(DECODE(LEAST(2000, e.sal), 2000, 2000, e.sal)) from emp e;
DECODE allows you to perform other more complex cases
Paul Scott
aspscott_at_tcp.co.uk
^^ Remove 'as' Anti spam prefix
Received on Wed Nov 08 2000 - 19:03:47 CST
![]() |
![]() |