From the course: SQL Essential Training
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Grouping with the WHERE clause - SQL Tutorial
From the course: SQL Essential Training
Grouping with the WHERE clause
Now, it is possible to add criteria to queries that we've applied grouping to. Adding criteria to a group query works in the same way as with other queries that we've seen before. Using the WHERE clause allows us to add new criteria. So, let's consider a alteration of our original request by WSDA Music Management. They have now asked us what are the average invoice totals by city for only the cities that start with L. Now we can achieve the result of this request by making some alterations to our existing SQL statement. Let's go ahead and add a where clause to our query. And the where clause always comes after the from clause and before the group by. So let's go ahead and add where. And now we're interested in a subset of this data. We are now only interested in the billing cities that start with L. So let's include billing city. And we just wanna perform a partial search. So to do this, we include the like keyword and we are performing a search on a text data type, which is the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
Grouping your query results57s
-
(Locked)
Filtering with a grouped condition5m 48s
-
(Locked)
Grouping with the WHERE clause2m 7s
-
(Locked)
Grouping with the HAVING clause4m 17s
-
(Locked)
Grouping with the WHERE and HAVING clause2m 49s
-
(Locked)
Grouping by many fields2m 58s
-
(Locked)
Solution: Calculate Average spend per city2m 29s
-
-
-
-
-
-