Re: Median with standard SQL
Date: Wed, 11 Jul 2001 10:04:20 -0400
Message-ID: <9ihmd2$1jn$1_at_bob.news.rcn.net>
Your professor at the University of Illinois probably wants you to really think about this one and try lots of different things. Finding a ready-made answer in a newsgroup is not the best way to go in the long term. It is much better to try to figure it out on your own, so here is a hint:
The answer is constrained in the problem.
"Jess Likens" <likens_at_students.uiuc.edu> wrote in message
news:wPT27.633$oz3.8465_at_vixen.cso.uiuc.edu...
I
> don't think it works if there are multiple rows with identical values.
But
> thanks.
>
> -Jess
>
> "Aakash Bordia" <a_bordia_at_hotmail.com> wrote in message
> news:9ida78$vi6$1_at_stlnews.stl.ibm.com...
> > Hint....
> > select column from table O where (select count(*) from table where
> > column<O.column)=(select count(*)/2 from table)
> > Thanks
> > Aakash
> >
> > "Jess Likens" <likens_at_students.uiuc.edu> wrote in message
> > news:yqm27.364$oz3.4759_at_vixen.cso.uiuc.edu...
> > > Does anyone have a method to get the median of a relation using only
the
> > > following SQL commands: SELECT, DISTINCT, WHERE, FROM, LIKE, EXISTS,
IN,
> > > UNION, INTERSECT, EXCEPT/MINUS, ANY, ALL, COUNT, SUM, AVG, MAX, MIN,
GROUP
> > > BY, HAVING, ORDER BY, JOIN? I can't seem to come up with anything.
The
> > > median of n elements occurs at (n+1)/2 for an odd number of elements
and
it
> > > is the average of n/2 and n/2 and (n+1)/2. Any help would be much
> > > appreciated.
> > >
> > > -Jess
> > >
> > >
> >
> >
>
>
Received on Wed Jul 11 2001 - 16:04:20 CEST