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

Home -> Community -> Usenet -> c.d.o.server -> Re: How to select top n rows from a table?

Re: How to select top n rows from a table?

From: Clark Morrow <zzz.cemorrow_at_kodak.com>
Date: Wed, 7 Apr 1999 20:52:27 -0400
Message-ID: <7egun9$6gf$1@news.kodak.com>


Interesting...
But it returns the BOTTOM n. I doubt that you could force the group by to go in descending sequence to get the TOP n.

Oracle 8i will have a rank function that can be used to return the top n.


Michael Myers wrote in message <37097D2F.E0145D2C_at_blazenet.net>...

>SQL> create view student_view as select score, name
> 2 from students
> 3 group by score, name;
>
>SQL> select rownum, name, score
> 2 from student_view
> 3 where rownum < 4;
>
> ROWNUM NAME SCORE
>--------- --------------- ---------
> 1 Jake 15
> 2 Fred 20
> 3 Joe 50
>
>Group by may be 'cheating', but since students should be unique it
>should work....
Received on Wed Apr 07 1999 - 19:52:27 CDT

Original text of this message

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