How to get last page no like stackoverflow.com pagination in Sql server 2005
+2
A:
Try somethign like this
DECLARE @NumberPerPage INT
SELECT @NumberPerPage = 50
SELECT CEILING(COUNT(*) / CAST(@NumberPerPage AS FLOAT)) NumberOfPages
FROM TABLE
astander
2009-11-10 05:18:57
Thanks man i ll try it
Pandiya Chendur
2009-11-10 05:22:40
+2
A:
Assuming a page size of 10:
select case when count(*) % 10 = 0 then count(*)/10 else count(*)/10 + 1 end as lastPageNumber from posts;
As you can see, it's a little tedious to do this kind of stuff purely in SQL. What high level language are you using? You can implement the logic in your programming language and then just do this SQL query to get the count of the number of items:
select count(*) from posts;
Asaph
2009-11-10 05:19:34