Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: DECODE OR CASE
"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
![]() |
![]() |