Get the number of queries in sql

I have a request:

SELECT TOP 100 *
FROM   TABLE1 T1
INNER JOIN TABLE2 T2 ON T1.ID = T2.ID
WHERE  T1.........

How can I get the number of rows returned by the request, with the exception of the top 100. I want to return 100 records, as well as the total number of registered records. Is there an easier way to do this, and not just write the entire query without the top keyword and enable the account? eg:

SELECT COUNT(1) AS TableCount
FROM   TABLE1 T1
INNER JOIN TABLE2 T2 ON T1.ID = T2.ID
WHERE  T1.........
+5
source share
1 answer

Using COUNT (1) OVER () In the table in the Total_Count column, you will get no records in the table.

SELECT TOP 100 *, COUNT(1) OVER() as 'Total_Count'
FROM   TABLE1 T1
INNER JOIN TABLE2 T2 ON T1.ID = T2.ID
WHERE  T1.........
+2
source

All Articles