Is it possible to do a paging type of query where my main query has a group by clause in it.
How would I implement this (if this is even possible)
Example query:
SELECT * FROM TABLE_NAME GROUP BY DATEPART(YEAR,DATE), DATEPART(YEAR,MONTH)
Can I possibly get the result via reading it page by page?
…and while on the topic, can I also get the total number of rows that would be retrieved without putting it inside a sub query?
Use
ROW_NUMBER& CTE feature of SQL Server as mentioned below.Please refer http://sqlserverplanet.com/sql/pagination-using-rownumber for more details.