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

Home -> Community -> Usenet -> c.d.o.misc -> Re: select nth row ?

Re: select nth row ?

From: Peter Chang <p-chang_at_ti.com>
Date: Thu, 23 Apr 1998 11:53:52 -0500
Message-ID: <353F7220.99CB2B2A@ti.com>


select a.ord_col, a.other_stuff
  from table_name a
 where Nth_row >(select count(*) from table_name b where b.ord_col = a.ord_col)  order by a.ord_col;

Phil R Lawrence wrote:

> Hello,
>
> I am treating the results of an ordered query as a data set. As such, I am
> interested in determining the mean and interquartile range. This means I need
> to be able to select the nth row of the *ordered* data set. Now, I thought I
> might use ROWNUM, but my manual says "ROWNUM is assigned before the rows are
> ordered [by the ORDER BY clause]."
>
> Any ideas on how I can do this? If I can't get Oracle to do this I'll have to
> slurp the whole data set into my program and do the calcs there.
>
> Thanks!
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Phil R Lawrence phone: 610-758-3051
> Programmer / Analyst e-mail: prl2_at_lehigh.edu
> 194 Lehigh University Computing Center
> E.W. Fairchild - Martindale, Bldg. 8B
> Bethlehem, PA 18018
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Received on Thu Apr 23 1998 - 11:53:52 CDT

Original text of this message

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