File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Oracle/OAS and the fly likes getting top 10 rows Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Reply Bookmark "getting top 10 rows" Watch "getting top 10 rows" New topic
Author

getting top 10 rows

sumit malik
Greenhorn

Joined: Oct 31, 2001
Posts: 21
hi,
i hav one simple but ?? problem..can any one tell me how to fetch first 10 or last 20 rows from a table which contains 100 records...
thanx in advance...
Remar Uy
Ranch Hand

Joined: Mar 18, 2002
Posts: 35
select *
from emp
where rownum < 11
/
sumit malik
Greenhorn

Joined: Oct 31, 2001
Posts: 21
Originally posted by Remar Uy:
select *
from emp
where rownum < 11
/

thanx...but i think this is not a proper solution ...i guess there r some functions like TOP to fetch rows...and how can i fetch last 40 rows ..using this method..
Lipman Li
Ranch Hand

Joined: May 02, 2002
Posts: 122
select * from
(select * from emp order by rownum desc)
where rownum < 41;
you'll get the last 40 records.
SJ Adnams
Ranch Hand

Joined: Sep 28, 2001
Posts: 925
select name from
(select rownum a, name from emp )
where a > 60
?
Remar Uy
Ranch Hand

Joined: Mar 18, 2002
Posts: 35
Hi,
If you're using 8.1.7 and above, you can use Rank.
Hth.
 
 
subject: getting top 10 rows
 
Threads others viewed
Multiple selection in JTable
Initial rows loaded to result set
Show retrived rows while fetching from database
how can we sent the material value
Using checkbox & textfield together
IntelliJ Java IDE