From: Aditya on
Hi Ken,

You can get the total record count by using the OVER keyword. For the code you provided, make changes like below.

With Cust AS
( SELECT CustomerID, CompanyName,
ROW_NUMBER() OVER (order by CompanyName) as RowNumber,
COUNT(*) OVER () As TotalCount
FROM Customers where Country in ('US', 'CN'))
select *
from Cust
Where RowNumber Between 20 and 30

Note that I added the following line of code to your Code.
COUNT(*) OVER () As TotalCount
The Column TotalCount which now appears in each row will give you the Total Number of Records which you have to handle in your application.

Thanks,
Aditya.