Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: first registers
"Pilar Lorenzo" <pilar_lorenzo_at_latinmail.com> wrote in message news:<a1mhei$knk$1_at_talia.mad.ttd.net>...
> Hello.
> I have a select, and it has ten registers but I need only the five first.
>
> In sqlserver I can do:
>
> select top 5 * from emp;
>
> but oracle I can not do it.
>
> thanks and excuses but english.
Here is one way to return the top or bottom N:
UT1> l
1 select ename, sal
2 from ( select ename, sal from emp order by sal desc )
3* where rownum < 6
UT1> /
ENAME SAL
---------- ----------
KING 5000 SCOTT 3000 FORD 3000 JONES 2975 BLAKE 2850