Computing Totals and Subtotals

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


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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.