Database Reference
In-Depth Information
Figure 5-7. Using GROUP BY to aggregate values
If you will scroll the result set down to the Redmond, then you will see that it shows 121 rows, as you
saw in Figure 5-6.
How It Works
You specify the City column and use the COUNT function to count the total number of cities listed for each
address in the Address table.
Select City, count(City) AS 'Total Count'
from Person.Address
The GROUP BY clause enforces the grouping on the specified columns, and the results should be
displayed in the form of groups for the City column.
group by City
The ORDER BY clause ensures that the result shown will be organized in the proper sequential order
based upon city.
order by City Asc
 
Search WWH ::




Custom Search