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

Home -> Community -> Usenet -> c.d.o.misc -> Re: DECODE OR CASE

Re: DECODE OR CASE

From: Olaf Musch <Olaf.Musch_at_computer.org>
Date: Fri, 2 Jul 2004 14:11:27 +0200
Message-ID: <2kl1luF3c0lnU1@uni-berlin.de>


"Oracle Newbie" <f93c0532_at_yahoo.com> schrieb im Newsbeitrag news:2kkeb3F3d8cjU1_at_uni-berlin.de...

a real name would be nice

> How is it possible to use the DECODE function or CASE statement to implement
> some thing like this
>
> If salary >= 1200 and salary < 1300 then
> grade := 1;
> elsif salary >= 1300 and salary < 1500 then
> grade := 2;
> elsif salary >= 1500 and salary < 2000 then
> grade := 3;
> else
> grade := 4;
>
> end if ;
>

Well, first you should take a look into the manuals In contrast to others, Oracle manuals are real good stuff to read.

But here's an example:

select
  name
, case
  when (salary >= 1200) and (salary < 1300) then     1
  when (salary >= 1300) and (salary < 1500) then     2
  when (salary >= 1500) and (salary < 2000) then     3
  else
    4
  end as grade;
from emp;

HTH Olaf Received on Fri Jul 02 2004 - 07:11:27 CDT

Original text of this message

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