Q&A

Q1:Why does SQL Server tell me that only one row is affected when it returns an aggregate result? For instance, in this query where 31 non-null customer regions were found, the server only reported (1 row(s) affected).
select count(Region) "Customers with Region"
  from Customers

Customers with Region
---------------------
                   31

(1 row(s) affected)
A1: The number of rows in the rowcount report is only the size of the ultimate result set. Regardless of how many rows are touched by an aggregate function, the final result is just the single reported value.
Q2:Can I use ROLLUP and CUBE in the same statement?
A2: No. You can only use one or the other.
Q3:How many columns can I include in my GROUP BY clause?
A3: There is no stated limit to the number ...

Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.