DelphiFAQ Home Search:

How can I limit the number of rows in Oracle

 

comments32 comments. Current rating: 5 stars (15 votes). Leave comments and/ or rate it.

Question:

I have got a query that returns thousands of rows but I'm only interested in the first 20 records. In mysql I can limit the returned data (and thus the network traffic) with the LIMIT start,number clause, where start is the starting row and number is the number of rows that I want to see.

Is something similar possible in Oracle as well?

Answer:

Oracle has a system attribute ROWNUM for each record returned. A query that only returns the first 20 records would look like the one in the example.

ROWNUM starts counting with 1.

// mysql
select col from tbl limit 20;

// Oracle
select col from tbl where rownum<=20;

// Microsoft SQL
select top 20 col from tbl;

Content-type: text/html

Comments:

You are on page 3 of 3, other pages: 1 2 [3]
2012-11-16, 11:36:20
Rodolfo C from Monterrey, Mexico  
rating
Muchas gracias!!!
2012-12-19, 00:08:12
anonymous  
[url= http://www.wonderfu..tml]ibeats earphones[/url] is characterized by its solid housing,sllyjfdibeats balanced sound quality and purest sound producing. Monster Ibeats have Solid metal housing resists vibrations for purest sound without sonic side effects ControlTalk on-cable mic for convenient hands-free calling with iPhones and smartphones ControlTalk track seeking capabilities without touching your iPod or music phone. This [url= http://www.wonderfu..tml]ibeats earphones[/url] unlike ordinary in-ear headphones,ibeats earphones are constructed from solid metal housing.With the [url= http://www.hotmusic..html]beats by dre mixr[/url], you can freely enjoy the beautiful music without being disturbed by the outside noise.We supply all kinds of beautiful Monster [url= http://www.wonderfu..com/]Beats by dre[/url], such as ibeats earphones,[url= http://www.wonderfu...html]solo hd bluetooth[/url],[url= http://www.hotmusic..com/]beats studio headphones[/url] and [url= http://www.hotmusic..om/]purple beats by dre[/url]
You are on page 3 of 3, other pages: 1 2 [3]

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: