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: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Wed, 3 Feb 1999 09:47:01 -0000
Message-ID: <918035214.7119.0.nnrp-07.9e984b29@news.demon.co.uk>


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}
        )

The result you are after has to be either max(col) or min(col), depending on sign. If abs(max(col)) is larger than abs(min(col)) then you want max(col), otherwise you want min(col).

There is a problem with your requirement if the two extreme values are -10 and +10 say, which to you want to see ?

Jonathan Lewis
Yet another Oracle-related web site: www.jlcomp.demon.co.uk

Derek Sorensen wrote in message
<01be4f51$48aa05c0$570610ac_at_pc1879.tnagb.com>...
>Hi,
>
>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 - 03:47:01 CST

Original text of this message

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