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: Paul Scott <pscott_at_tcp.co.uk>
Date: Thu, 09 Nov 2000 01:03:47 +0000
Message-ID: <k8tj0t4vlqvv0m7cfkb9mese2cuf69c8o1@4ax.com>

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

Original text of this message

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