Re: median value
From: janet <janet_at_telesph.com>
Date: 1996/12/12
Message-ID: <32B014EB.260B_at_telesph.com>#1/1
from table
where rownum <= <---- rownum is processed (select count(*) / 2
from table)
order by col) <---- AFTER this order by - is this true?
Date: 1996/12/12
Message-ID: <32B014EB.260B_at_telesph.com>#1/1
Roger, sorry, I don't think that provides the median.
Ex: 5 numbers: 1 2 3 4 20
your answer would provide 4 (avg=6)
when it should be 3.
Lisa, maybe something like
select max(col)
from table
where col= <---- this where only works if this(select col
from table
where rownum <= <---- rownum is processed (select count(*) / 2
from table)
order by col) <---- AFTER this order by - is this true?
hth,
janet
Roger Wernersson wrote:
>
> Lisa Kilroy wrote:
> > I need to pull the median value out of a table for a particular field.
>
> Hello Lisa, no problem!
>
> SELECT MAX (value)
> FROM table
> WHERE value <= (
> SELECT AVG (value)
> FROM table
> )
>
> This might not be the fastest way but it works.
>
> --
> Sport radio: people listening to people watching people having fun
> Mailto:roger.wernersson_at_adra.se
> BTW: All opinions are mine, all mine, and nobody's but mine.
Received on Thu Dec 12 1996 - 00:00:00 CET