Path: news.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!newsfeed.news2me.com!arclight.uoregon.edu!logbridge.uoregon.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail
From: JusungYang@yahoo.com (Jusung Yang)
Newsgroups: comp.databases.oracle.misc
Subject: Re: how to compute median ?
Date: 10 Oct 2002 10:23:39 -0700
Organization: http://groups.google.com/
Lines: 29
Message-ID: <130ba93a.0210100923.6e3c53dc@posting.google.com>
References: <2002109-101537-355947@foorum.com> <130ba93a.0210090916.399365ef@posting.google.com> <3da540b8$0$79635$edfadb0f@dspool01.news.tele.dk>
NNTP-Posting-Host: 64.160.46.136
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1034270619 5661 127.0.0.1 (10 Oct 2002 17:23:39 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 10 Oct 2002 17:23:39 GMT
Xref: newsfeed1.easynews.com comp.databases.oracle.misc:87671
X-Received-Date: Thu, 10 Oct 2002 10:23:34 MST (news.easynews.com)

Well, nothing is wrong with the way I calculated the median, yes?
Though PERCENTILE_DISC(0.5) is a more direct approach in evaluating
the median. So instead of using the row_number and ceil like

select c1 from (select c1, row_number() over (order by c1) rn,
ceil(count(1) over()/2) mdn from
t2) where rn=mdn;

the SQL would become like

select c1 from (select c1, percentile_disc(0.5) within group (order by
c1) over() prn from t2)
where c1=prn;


But yes, percentile_disc(0.5) is more straight forward in getting the
median and is a bit easier to understand.


- Jusug Yang


"Finn Ellebaek Nielsen" <fen@changegroup.dk> wrote in message news:<3da540b8$0$79635$edfadb0f@dspool01.news.tele.dk>...
> This is incorrect. With the SQL analytic functions this is possible through
> PERCENTILE_DISC(0.5).
> 
> HTH.
> 
> Finn
