Home » SQL & PL/SQL » SQL & PL/SQL » Limiting results from a select statement
Limiting results from a select statement [message #374446] Tue, 12 June 2001 12:26 Go to next message
Jonathan Nordell
Messages: 2
Registered: June 2001
Junior Member
Is it possible to limit the number of rows returned by a select statement in oracle. It doesn't look like oracle supports the limit statement, and I haven't been able to find any other way to handle this.
Re: Limiting results from a select statement [message #374449 is a reply to message #374446] Wed, 13 June 2001 05:20 Go to previous messageGo to next message
John R
Messages: 156
Registered: March 2000
Senior Member
You can limit the number of rows returned by a query by adding the restriction
'AND rownum <= n'
to your query where n is the number of rows you want to see.
Note that this restriction is applied before any Order by statements.
order by and rownum [message #374454 is a reply to message #374446] Wed, 13 June 2001 06:57 Go to previous message
Hans
Messages: 42
Registered: September 2000
Member
In Oracle 8i you can limit the query

select * from emp
order by sal desc;

with

select * from (
   select * from emp
   order by sal desc
)
where rownum <= 5;

Previous Topic: composite key
Next Topic: plsql table check for double values
Goto Forum:
  


Current Time: Sat May 25 15:03:37 CDT 2024