From the course: Querying Microsoft SQL Server 2022

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Use GROUP BY and COUNT

Use GROUP BY and COUNT

- [Instructor] In the AdventureWorks database, there's a table called Person.Address. Let's go ahead and take a quick look at the data that it contains by running a simple SELECT statement against it. When I execute the query, you'll see that this table stores over 19,000 individual street addresses. One of the columns here is the City column, and this is the name of the city that the address is in. Here at the top, we have a whole bunch of addresses in the city of Bothell. There are potentially many addresses for each city, but if you scroll through the grid, you'll quickly see that the rows aren't in an order that makes it easy to view. We can add an ORDER BY clause into the query to help you visualize the number of addresses in each city. I'll add that onto line number three. We'll ORDER BY the city name. Now, when I execute the query again, the cities will be alphabetized so it makes it easier to see how many…

Contents