Grouping and Summarizing
Grouping is primarily performed in SQL Server by using the GROUP BY clause in a SELECT query to determine in which groups rows should be put. Data is summarized by using the SUM function. The simplified syntax is as follows:
SELECT Column1, SUM(Column2)FROM table_list[WHERE search_conditions]GROUP BY Column1
GROUP BY follows the optional WHERE clause and is most often used when aggregate functions are being utilized in the SELECT statement (aggregate functions are reviewed in more detail in Chapter 7).
5-1. Summarizing a Result Set
You need to know the total number of items in your ...