The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 Query by Slice, Parallel Execute, and Join: A Thread Pool Pattern in Java
Subject:  Trick for paging and finding number of rows
Date:  2008-02-07 12:42:04
From:  forinti


I use a little trick to page and find the total number of rows at the same time. This query gives me the first and last rows, as well as the page that was requested. Using ROW_NUMBER, you can cut the query to 2 selects.

select a, b, r from (
select a, b, rownum r from (
select a, b from test
order by a asc
) order by r desc
) where rownum=1 or r=1 or r between 20 and 30
order by r asc

 Feed java.net RSS Feeds