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

Home -> Community -> Usenet -> c.d.o.server -> Re: Help with DECODE

Re: Help with DECODE

From: Matt Brennan <mbrennan_at_gers.com>
Date: Fri, 01 May 1998 23:21:35 GMT
Message-ID: <01bd7557$dbca1360$049a0580@mcb>


You can use decode along with the sign function by subtracting the value of the magnitude column from 5.5, perform the sign function on the value of the difference, decode that result, and then return the desired final result.
--
Matt Brennan
SQL*Tools Specialist
GERS Retail Systems
9725-C Scranton Road
San Diego, California 92121
1-800-854-2263
mbrennan_at_gers.com

Radha Bala <radha.bala_at_amd.com> wrote in article <01bd7497$3fdb9200$54215f8b_at_cisp467>...
> I don't think, you can do this using DECODE.
> You can do this using a SQL statement
>
> SELECT id, type, 'faint'
> FROM
> astro
> WHERE magnitude < 5.5
> UNION
> SELECT id,type,'very faint'
> from astro
> WHERE
> magnitude >= 5.5 ;
>
> -- Radha
>
> Alistair Thomson <alistair.thomson_at_spinxcst.co.uk> wrote in article
> <35470AA9.9538B9F5_at_spinxcst.co.uk>...
> > Hi
> >
> > I'm trying to get to grips with decode and am having difficulty in
using
> > expressions in decode. An example of the data is shown below:
> >
> > When I use decode like this
> >
> > select id, type, decode(magnitude,5.5,'faint',8.4,'very faint') from
> > astro;
> >
> > I get the following:
> >
> > M33 Galaxy 5.7
> > M34 Cluster 5.5 faint
> > M39 Cluster 5.2
> > M40 Double Star 8.4 very faint
> >
> > What I really want to do is say that everything < 5 is visible and >= 5
> > is not visible. But when the decode looks like this I get an error:
> >
> > select id, type, decode(magnitude,<5.5,'faint',>=5.5,'very faint') from
> > astro;
> >
>
>
Received on Fri May 01 1998 - 18:21:35 CDT

Original text of this message

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