Explains how to filter a result set on its grouped data, rather than filtering the rows to be grouped (as with the WHERE clause)
- [Instructor] Now if we want to apply a filter…to the new data we've created, this count function here,…we would use HAVING.…HAVING is like a WHERE clause for aggregated data,…or grouped data.…It's a good tip to make sense of SQL queries in sections.…So first of all, we've got SELECT, FROM and WHERE,…if there were to be a WHERE clause.…Then we have GROUP BY, and HAVING,…if there is a HAVING clause.…
And then finally, we have our ORDER BY at the end.…And SQL queries always follow this pattern.…So let's use one.…Now we're going to say HAVING count (district)…greater than 8.…And you can see it's returned us where the count…are 9 and 10, and instead of repeating the aggregation,…we can just use the alias there that we've got, ct.…
So we could say HAVING ct greater than 8.…And that returned us exactly the same thing.…Generally speaking, when building a query,…you would select the thing…that you're also going to group by,…but you don't have to.…So you could run.…So you could just return the districts without the count.…
Join Emma Saunders as she shows you how to design and write simple SQL queries for data reporting and analysis. Review the different types of SQL, and then learn how to filter, group, and sort data, using built-in SQL functions to format or calculate results. Learn a bit about data types and database design. Discover how to perform more complex queries, such as joining data together from different database tables. Last but not least, Emma shows how to save your queries as views, so you can run them again and again.
- Using different versions of SQL
- Retrieving data with SELECT statements
- Filtering and sorting your results
- Transforming results with built-in SQL functions
- Grouping SQL results
- Merging data from multiple tables
- Identifying data types, and how to make sense of your database design
- Saving SQL queries
Skill Level Intermediate
1. Use SQL to Report Data
Data types in SQL databases5m 47s
2. Group your SQL Results
3. Merge Data from Multiple Tables
4. Advanced Features and Taking Your Learning Forwards
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.