permaculture playing cards*
The moose likes Oracle/OAS and the fly likes Values not  retireved using rownum in oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Values not  retireved using rownum in oracle" Watch "Values not  retireved using rownum in oracle" New topic
Author

Values not retireved using rownum in oracle

Prashanth Chandra
Ranch Hand

Joined: Dec 07, 2005
Posts: 79
Hi All,
I have writte a query which retirves data from table using the rownum attribute which works fine:

select * from (select id,count(*) from average a where rownum <= (select count(*) from average) group by id) where rownum < 65501

But when I am trying to retieve the value above 65501 I am not able to fetch the records from the table. Please fine the below which is not working

select * from (select id,count(*) from average a where rownum <= (select count(*) from average) group by id) where >= 65501

Can anyone please let me know how I can retireve the data based on the above query.

Thanks in advance
regards
Prashanth
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

Prashanth,
If I remember correctly, Oracle only allows less than or equal to logical operators with rownum pseudo-column.
Hence your query using greater than operator does not work.
I'm only guessing, but I think you may be able to use the "between" operator, as in:

Good Luck,
Avi.
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
This is your original query (see the comments next to your code):



Run the following:



to find the total number of rows associated with the ID group by clause... but as written... you are always showing the numbers for all your rows grouped by ID.
[ October 30, 2008: Message edited by: Paul Campbell ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Values not retireved using rownum in oracle
 
Similar Threads
Difference between rowid and rownum in sql query??
oracle record fetch
Selecting random rows
SQL Query formation problem.
Using Rownum in JDBC