Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to select top n rows from a table?
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
![]() |
![]() |