How to include the total number of returned rows in the resultset from SELECT T-SQL command?
Posted
by quarkX
on Stack Overflow
See other posts from Stack Overflow
or by quarkX
Published on 2010-05-12T17:47:56Z
Indexed on
2010/05/12
17:54 UTC
Read the original article
Hit count: 234
I would like to ask if there is a way to include the total number of rows, as an additional column, in the returned result sets from a TSQL query using also the Row_Number (SQL 2005) command. For example, getting the results set from a query against Book table in a form similar to this:
RowNum BookId BookTitle TotalRows
--------------------------------------------
1 1056 Title1 5
2 1467 Title2 5
3 121 Title3 5
4 1789 Title4 5
5 789 Title5 5
© Stack Overflow or respective owner