Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Median function in SQL
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