By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

How to use "rownum"

P: 2
Hi,
I am doing a paging task. In order to do that I want to get data 10 by 10 raws from a table. How can I do this using "rownum" ?
I tried in this way

SELECT FROM (
SELECT UPLOAD_DATE_TIME,TYPE_OF_UPLOAD,PERFORMED_BY,STATU S,CLFILE_COUNT,STCMAS_COUNT,CLSTMAS_COUNT,OPENTRN_ COUNT,START_TIME,FINISH_TIME,rownum rn
FROM ONLINE_ACTION_HISTORY where TYPE_OF_UPLOAD='OPERATIONAL' ORDER BY UPLOAD_DATE_TIME DESC) WHERE rn between 1*10-9 and 1*10;

But row numbers are not in the order as table rows. It has different order. Please help me to solve this problem.
Thanks in advance
Nov 10 '10 #1
Share this Question
Share on Google+
2 Replies


amitpatel66
Expert 100+
P: 2,367
Try this:

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM(
  2. SELECT UPLOAD_DATE_TIME,TYPE_OF_UPLOAD,PERFORMED_BY,STATU S,CLFILE_COUNT,STCMAS_COUNT,CLSTMAS_COUNT,OPENTRN_ COUNT,START_TIME,FINISH_TIME,rownum rn FROM (
  3. SELECT UPLOAD_DATE_TIME,TYPE_OF_UPLOAD,PERFORMED_BY,STATU S,CLFILE_COUNT,STCMAS_COUNT,CLSTMAS_COUNT,OPENTRN_ COUNT,START_TIME,FINISH_TIME 
  4. FROM ONLINE_ACTION_HISTORY where TYPE_OF_UPLOAD='OPERATIONAL' ORDER BY UPLOAD_DATE_TIME DESC))
  5. WHERE rn between 1*10-9 and 1*10
  6. /
  7.  
Nov 15 '10 #2

P: 2
I tried it and it works
Thanx Amith... :)
Nov 16 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.