Můžete použít Row_Number()
ve vašem dotazu a objednávce SubscribeId
sestupně a row[0]["RowNumber"]
je celkový počet takto:
Select
* ,
ROW_NUMBER() OVER ( ORDER BY SubscribeId DESC) as RowNumber
From billing.BillMaster As BM
Where
( Bm.SubscribeId = '12345674' )
Order by SubscribeId
OFFSET @PageNumber * @RowCount ROWS
FETCH NEXT @RowCount ROWS ONLY;