That's not correct. This will give you the mean and not median.
I have this script in my library taken from somewhere I don't remember. I
have not tested it. Please make SURE it works as desired.
Sandeep
select avg(v.the_number_column) the_median
from (
select rownum the_rownum,
v.the_number_column
from (
select t.the_number_column
from the_table t
where t.the_number_column is not null
order by t.the_number_column
) v
) v
where v.the_rownum = (
select floor(count(t.the_number_column)/2)
from the_table t )
or v.the_rownum = (
select ceil(count(t.the_number_column)/2)
from the_table t )
-----Original Message-----
From: Sinkiewicz, Gerald P [mailto:[Email Address Removed] Wednesday, October 31, 2001 8:47 AM
To: LazyDBA.com Discussion
Subject: FW: finding the median
Median(list)= (max(list)+min(list))/2.
-----Original Message-----
From: Michael McMullen [mailto:[Email Address Removed] Wednesday, October 31, 2001 8:41 AM
To: LazyDBA.com Discussion
Subject: finding the median
Hello
Anybody ever come up with a way to get the median from a list of values.
Thanks
Mike
[Email Address Removed]Oracle LazyDBA home page