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: TurkBear <jgreco1_at_mn.rr.com>
Date: Tue, 15 Jan 2002 15:25:12 -0600
Message-ID: <97794u4h3r4k1jcqm9mmukm1kbdekh1npv@4ax.com>

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" <noemail_at_noemail.com> wrote:

>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

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World!  Check out our new Unlimited Server. No Download or Time Limits! -----== Over 80,000 Newsgroups - 19 Different Servers! ==----- Received on Tue Jan 15 2002 - 15:25:12 CST

Original text of this message

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