Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Is there a "maximum magnitude" function?
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
![]() |
![]() |