You can do both in one query using the OVER clause on another COUNT
select
count(*) RecordsPerGroup,
COUNT(*) OVER () AS TotalRecords
from temptable
group by column_1, column_2, column_3, column_4
More Related Contents:
- Does T-SQL have an aggregate function to concatenate strings? [duplicate]
- Include missing months in Group By query
- How do I create a unique constraint that also allows nulls?
- How do I get list of all tables in a database using TSQL?
- Get first day of week in SQL Server
- What is the significance of 1/1/1753 in SQL Server?
- Cannot truncate table because it is being referenced by a FOREIGN KEY constraint?
- Escape a string in SQL Server so that it is safe to use in LIKE expression
- Insert Update trigger how to determine if insert or update
- SQL time difference between two dates result in hh:mm:ss
- What is the best way to truncate a date in SQL Server?
- Dynamic SQL (passing table name as parameter)
- SQL Server: Difference between PARTITION BY and GROUP BY
- How do you truncate all tables in a database using TSQL?
- Understanding SQL Server LOCKS on SELECT queries
- SQL Server: How to select all days in a date range even if no data exists for some days
- SQL – The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
- TSQL: How to convert local time to UTC? (SQL Server 2008)
- T-SQL Dynamic SQL and Temp Tables
- Find non-ASCII characters in varchar columns using SQL Server
- How can I determine in SQL Server if a dateTime range overlaps another
- How do you change the datatype of a column in SQL Server?
- SQL Server Query – groupwise multiplication
- Getting week number off a date in MS SQL Server 2005?
- How to reuse calculated columns avoiding duplicating the sql statement
- How do I move a table into a schema in T-SQL
- How to use RANK() in SQL Server
- How to wait for 2 seconds?
- What is the meaning of “#” in front of a table name in TSQL?
- T-SQL for finding Redundant Indexes