Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Median and Geometric Mean in Oracle?

112 views
Skip to first unread message

david...@yahoo.com

unread,
Nov 11, 1999, 3:00:00 AM11/11/99
to

Hello all,

I want to calculate the median and G. mean of a group of values. Did
Oracle provide these two functions?

If not, could anyone tell me how to get the median and G. mean of a
group of numbers?

Thanks,
David


Sent via Deja.com http://www.deja.com/
Before you buy.

Jonathan Lewis

unread,
Nov 11, 1999, 3:00:00 AM11/11/99
to

Median is difficult, it's pretty much a procedural
thing, so I'll skip that one (for the moment at least)

Is the geometric mean the:
reciprocal of the average of the reciprocals
or
the Nth root of the product of N values ?

I think the former would be:
select 1/(sum(1/col)) from tab;

and the latter could be
select exp( sum( ln(col) ) / count(col) ) from tab


--

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

david...@yahoo.com wrote in message <80d4pj$q83$1...@nnrp1.deja.com>...

Connor McDonald

unread,
Nov 11, 1999, 3:00:00 AM11/11/99
to Jonathan Lewis


select x.total
from table x, table y
where (appropriate joins)
group by x.total
having
sum(sign(1-sign(y.total-x.total))) in
( trunc((count(*)+1)/2), trunc((count(*)+2)/2) );

or something like that should give the median...
--
===========================================
Connor McDonald
"These views mine, no-one elses etc etc"
connor_...@yahoo.com

"Some days you're the pigeon, and some days you're the statue."

0 new messages