I select records that may contain duplicates, I need to be able to split the result set into separate elements.
At the moment, I have the following (simplified) query:
SELECT pagiWrapper.* FROM ( SELECT DISTINCT alias.id , alias.name , DENSE_RANK() OVER (ORDER BY alias.name ASC) AS 'paginationRowNo' , COUNT(*) OVER(PARTITION BY 1) AS 'paginationTotalRows' FROM MyTable alias LEFT JOIN MyTableTwo alias2 ON alias2.id = alias.id WHERE ( ) ) pagiWrapper WHERE pagiWrapper.paginationRowNo > 0 AND pagiWrapper.paginationRowNo <= 15
There are 10 records in this result set, however DISTINCT correctly returns 3, and DENSE_RANK correctly marks them 1 , 2 and 3
My paginationTotalRows problem still returns 10 (the original duplicate) in the number of results, how can I change the query so that paginationTotalRows returns the correct amount?
source share