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: Sort and Limit Result

Re: Sort and Limit Result

From: Marinos <noemail_at_noemail.com>
Date: Tue, 15 Jan 2002 23:50:06 +0200
Message-ID: <a22855$5of$1@usenet.otenet.gr>


i'm using sql plus 3.1 and i don't think that the order by in the subquery is working

--




"TurkBear" ...

>
> Try this ( assuming you have a version of Oracle that supports it..(you
failed to mention which you have))
>
> Select name,points from ( select name,points from table order by points
desc) where rownum < 4 order by name,points desc;
>
> ( The subquery sorts the table by points high to low, then the main query
limits the result set to the first ( in this case
> the top ) 3 records and sorts the result)....
>
> hth,
>
>
"Marinos" ..
> >I have a table like this
> >name char
> >points number
> >dicom number
> >.
> >.
> >.
> >
> >How can i sort the table contents by points and show only the 3 lines
with
> >the biggest values?
> >I have tried the rownum command with order by (select name, points from
> >table where rownum between 1 and 3 order by p desc;) but it's useless
> >it doesn't sort the whole table but only the first (inserted) 3 lines.
> >
> >any solution?
> >
> >Thanks in advance
Received on Tue Jan 15 2002 - 15:50:06 CST

Original text of this message

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