Pagination in Oracle 10g

Oracle lacks the simplicity of MySql’s LIMIT syntax. It does, however, let you use Analytic Functions to get total record counts before pagination all in the same query (and performs pretty well doing so). Here, mostly for my reference, is how you might build a paginated query in Oracle:

select * from (
	select /*+ FIRST_ROWS(n) */
		, ROWNUM rnum
		, count(*) over() as total_rows
	from ( 
		/* your select statement goes here */ 
	) a
) b 
where b.rnum >= :start_row and b.rnum <= :end_row