Computing Totals and Subtotals

You can use other aggregate functions to obtain summarizations and totals of data in your tables.

Tip

All the modifiers you’ve learned to use for the COUNT function are available for any other aggregate function.

Computing Totals

You have to obtain totals to answer questions like: “How much money did we get from sales?” or “How many units have we sold of this product?” You could count records using a custom application. However, you will be able to get the desired information more efficiently by directly querying the database.

Using SUM

The SUM function does exactly what you would expect: it yields the sum of values ...

Get Microsoft® SQL Server™ 2005: Applied Techniques Step by Step 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.