Working with Aggregate Functions
All the functions you learned about yesterday are row-based: The function acts only on columns in the current row. Aggregate functions act on a set of rows. What are aggregate functions? You probably know them better as the summary, average, minimum, maximum, and count functions. "To aggregate" means to collect or to bring together. So, aggregate functions gather together data from many rows and report it in a single row (see Figure 4.1).
Figure 4.1. Aggregate functions gather values from many rows in a table into a single row in the result set.
SQL Server supports six aggregate functions:
SUM()—Total of all values; ...
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.