Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: computing median

Re: computing median

From: Scott Watson <swatson_at_datachest.com>
Date: Fri, 20 Apr 2001 19:38:56 GMT
Message-ID: <kf0E6.605064$Pm2.10023557@news20.bellglobal.com>

I don't believe there is a function that does that you need. The only solution is to write one yourself in PL?SQL.

eg exec :median := my_stats.median(tablename, column_name);

inside the function you would have to calculate the number of rows in the column and then if it is odd take the middle value or else use the two values around the center and add them together and divide by 2.

Scott.

"Herwig Henseler" <hh_at_ecce-terram.de> wrote in message news:hh-2D0C99.18481320042001_at_news.f.via-net-works.de...
> Hi experts,
>
> [Oracle 8i 8.1.7]
>
> How do I compute the Median of values in a table? I guess this must be a
> FAQ but haven't found an answer so far. The median is the value in the
> "middle" of a sorted list of values. That is, half of all values are
> bigger and the other half is smaller than the median.
>
> TIA,
> Herwig
>
> --
> ECCE TERRAM Internet Services GmbH Dr. Herwig Henseler
> E-Business & Webagentur Tel. 0441 / 500 12-0
> Heinrichstr. 18d Fax. 0441 / 500 12-29
> 26131 Oldenburg URL: http://www.ecce-terram.de
> "Since I've solved all our Y2K problems, I will be on vacation from
> 28th Dec 1999 to 6th Jan 1900."
Received on Fri Apr 20 2001 - 14:38:56 CDT

Original text of this message

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