Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Using Ranges in DECODE function -- Possible???
<swhedges_at_my-deja.com> wrote in message news:8jdo0p$ti4$1_at_nnrp1.deja.com...
> is it possible to utilize a range of values in the Search fields?
>
> example:
>
> decode(tenure,between 0 and 30, 1, 0)
>
> seems like it ought to work, but everytime i try this syntax SQL Plus
> says "Missing Expression"
>
> if i try writing it like such:
>
> decode(tenure,tenure between 0 and 30, 1, 0)
>
> i'm told "missing right parenthesis" starting at the between
>
> i can't believe that i would have to write the query like this:
>
> decode(tenure,0,1,
> 1,1,
> 2,1,
> 3,1,
> etc,etc from 4 through 30
> 0)
>
> do I???
>
> thanks in advance
>
> stuart
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Yes it is possible.
You need to implement
<= as sign(tenure - 30)
and >= as sign(tenure),
so you'll need two nested decodes.
Hth,
Sybrand Bakker, Oracle DBA Received on Thu Jun 29 2000 - 00:00:00 CDT
![]() |
![]() |