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: Is there a "maximum magnitude" function?

Re: Is there a "maximum magnitude" function?

From: Derek Sorensen <derek.sorensen_at_tnsofres.com>
Date: 3 Feb 1999 11:00:59 GMT
Message-ID: <01be4f64$6ff4f140$570610ac@pc1879.tnagb.com>


Jonathan,

Marvellous - many thanks for the prompt response. I had thought of using decode but couldn't quite see how to do it.

As to which value to use if they are equal, it doesn't really matter. I just wanted to preserve the sign of the "largest", but also avoid getting the situation where I reported, e.g. 5 when the largest in magnitude was e.g. -15.

Regards,

Derek Sorensen

Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk> wrote:

> Unless I've worked it out incorrectly:
> decode(
> sign(abs(max(col)) - abs(min(col))),
> 1,max(col), -1, min(col), 0,{your choice here}
> )
>
> There is a problem with your requirement if the two extreme
> values are -10 and +10 say, which to you want to see ?
>
> Derek Sorensen wrote in message

> >I want to use a group function to return the largest magnitude value for
a
> >column.
> >
> >e.g. if the column contains -10, 4, 5
> >
> >then:
> >
> > max(col) will return 5;
> >and:
> >
> > max(abs(col)) will return 10;
> >
Received on Wed Feb 03 1999 - 05:00:59 CST

Original text of this message

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