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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Mean/Median

RE: Mean/Median

From: Rajaram <rajaram_k_at_netzero.net>
Date: Tue, 15 May 2001 12:20:48 -0700
Message-ID: <F001.0030413D.20010515121711@fatcity.com>

I did a procedure for median some time back. Here is the algorithm that I used.

  1. Define a Cursor - Dont forget to use the Order by Column while defining. Ofcourse, U should order by the column on which you need median.
  2. Get a count of records that cursor would return ( Regarding How to get a count - U have to define a similar cursor with the same where clause but one that returns count ). Or, simply do a select count into variable.
  3. Supposing N is the number of records that the cursor would return,
  4. If N is Odd, Then (N/2)+1 th record is the the median record
  5. If N is even, then the average of the (N/2) th record and (N/2)+1 the record is the median value of the set.
  6. Now Loop thru the cursor until you encounter (N/2)+1 th record and then calculate the median as determined in the steps 4 and 5.

May be I goofed up somewhere - But I am sure my code worked - I checked it against a statistical package ( Cornerstone) generated median.

Correct me if I am wrong.
Rajaram.

-----Original Message-----
From: Tim Sawmiller [SMTP:sawmillert_at_state.mi.us] Sent: Tuesday, May 15, 2001 3:27 PM

To:     Multiple recipients of list ORACLE-L
Subject:        RE: Mean/Median

Well, no, it doesn't work at all. The definition of Median is a value where half your list of values is above, and half is below. If the values all tend toward the mininum or the maximum, this "equation" would be way out of line.

>>> MohanR_at_STARS-SMI.com 05/15/01 01:35PM >>> Oops, this only works for *even* numbers of samples....geez....

|| -----Original Message-----
|| From: Mohan, Ross
|| Sent: Tuesday, May 15, 2001 12:28 PM
|| To: 'ORACLE-L_at_fatcity.com'
|| Subject: RE: Mean/Median
||
||
|| geez louise,
||
|| Median := avg(Max,Min)
||
|| || -----Original Message-----
|| || From: Pat Hildebrand [mailto:pat_at_ssc.upenn.edu]
|| || Sent: Monday, May 14, 2001 10:56 PM
|| || To: Multiple recipients of list ORACLE-L
|| || Subject: Re: Mean/Median
|| ||
|| ||
|| ||
|| || >
|| || > Any scripts (sql or pl/sql) out there to compute various
|| || statistical things
|| || > in Oracle?
|| || >
|| ||
|| || Would depend on just what you are looking for. A quick look at
|| || Oracle's SQL functions showed avg, st. deviation, and variance
|| || although no median but that should be easier to write than
|| || some of the
|| || others.
|| ||
|| || Pat
|| || --
|| || Please see the official ORACLE-L FAQ: http://www.orafaq.com
|| || --
|| || Author: Pat Hildebrand
|| || INET: pat_at_ssc.upenn.edu
|| ||
|| || Fat City Network Services -- (858) 538-5051 FAX:
|| (858) 538-5051
|| || San Diego, California -- Public Internet access /
|| || Mailing Lists
|| ||
|| --------------------------------------------------------------------
|| || To REMOVE yourself from this mailing list, send an E-Mail message
|| || to: ListGuru_at_fatcity.com (note EXACT spelling of
|| 'ListGuru') and in
|| || the message BODY, include a line containing: UNSUB ORACLE-L
|| || (or the name of mailing list you want to be removed
|| from). You may
|| || also send the HELP command for other information (like
|| subscribing).
|| ||
||

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Mohan, Ross
  INET: MohanR_at_STARS-SMI.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Tim Sawmiller
  INET: sawmillert_at_state.mi.us

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

NetZero Platinum
No Banner Ads and Unlimited Access
Sign Up Today - Only $9.95 per month!
http://www.netzero.net
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Rajaram
  INET: rajaram_k_at_netzero.net

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Tue May 15 2001 - 14:20:48 CDT

Original text of this message

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