Home » SQL & PL/SQL » SQL & PL/SQL » Pagination Query
Pagination Query [message #599895] Wed, 30 October 2013 02:04 Go to next message
rameshaimhigh@gmail.com
Messages: 10
Registered: October 2013
Junior Member
Hi,

Basically, we had requirement to show only 10 records per page.

So we are using the below Query

SELECT *
FROM ( SELECT d.*,
ROWNUM rnum
FROM ( SELECT level num
FROM DUAL
CONNECT BY LEVEL <= 50
)d
WHERE ROWNUM <= ( :p_page_no * :p_results_per_page)
)
WHERE rnum > ( ( :p_page_no -1 ) * :p_results_per_page)

But now we had some changed requirement like

If p_page_no = 1
then
i need to give result 1- 5
if p_page_no =2
i need to give result 6- 15
if p_page_no =3
i need to give result 16- 25
if p_page_no =4
vice versa
end if;

Can any one change this Query and get back to us. Since we are using this in complex Query please give us the solution without impact performance
Re: Pagination Query [message #599906 is a reply to message #599895] Wed, 30 October 2013 02:48 Go to previous message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

rnum >= decode(pageno, 1, 1, 6+10*(pageno-1))
rnum < decode(pageno, 1, 5, 15+10*(pageno-1))

Previous Topic: getting total and single name in one query
Next Topic: update with case using select
Goto Forum:
  


Current Time: Fri Apr 26 02:41:02 CDT 2024