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

Home -> Community -> Usenet -> c.d.o.server -> Re: Median function in SQL

Re: Median function in SQL

From: tzadkiel <tzadkiel_at_surfnetcity.com.au>
Date: 1998/03/09
Message-ID: <01bd4b3b$65740d60$66ce6ccb@default>#1/1

sorry, there's a typo in that. line 5 should read:

"or (a.revenue=b.revenue and a.rowid>=B.rowid)) ranked,"

oops.

tzad

tzadkiel <tzadkiel_at_surfnetcity.com.au> wrote in article <01bd4b39$2fdeedc0$66ce6ccb_at_default>...
> this was fun. one solution is like this:
>
> select ranked.company, ranked.revenue
> from (select a.company, a.revenue, count(*) ranking
> from companys a, companys b
> where a.revenue>b.revenue
> or (a.revenue=b.revenue and a.rowid>=a.rowid)) ranked,
> (select round(count(*)/2) median_point
> from companys) mp
> where ranked.ranking=mp.median_point
>
Received on Mon Mar 09 1998 - 00:00:00 CST

Original text of this message

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