
Explanation

Box 1: SELECT
Box 2: GROUP BY
Example:
When used with a GROUP BY clause, each aggregate function produces a single value covering each group,
instead of a single value covering the whole table. The following example produces summary values for each
sales territory in the AdventureWorks2012 database. The summary lists the average bonus received by the
sales people in each territory, and the sum of year-to-date sales for each territory.
SELECT TerritoryID, AVG(Bonus)as 'Average bonus', SUM(SalesYTD) as 'YTD sales'
FROM Sales.SalesPerson
GROUP BY TerritoryID;