I want to select fixed size of distinct rows (per page) from table + count of all rows (per query). There is my query without count of all rows:
select distinct takenBookTitle, user from Books
where user = 'username'
order by takenBookTitle
offset 0 rows fetch next 3 rows only
But with this result I need to retrieve count of all rows (without offset.. fetch).
If distinct wasn't necessary It would be done with count(*) OVER():
select takenBookTitle, user, count(*) OVER() AS count
from Books
where user = 'username'
order by takenBookTitle offset 0 rows fetch next 3 rows only
Result:
BookTitle1 userName1 10
BookTitle2 userName2 10
BookTitle3 userName3 10
But I want to count distinct rows but count() OVER()* doesn't allow it.