How to get total number of pages based on some condition rather than getting total count of the row of particular table