From the course: Database Foundations: Intro to Databases

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Filtering groups with HAVING

Filtering groups with HAVING

From the course: Database Foundations: Intro to Databases

Start my 1-month free trial

Filtering groups with HAVING

- [Instructor] The where clause is used to filter rows of data from your query results. When you want to filter out entire groups from the results, then you'll use the having clause. I currently have the query from the prior movie, that groups all of the products together by the category description. Let's run it to see where we're starting with. Now this database has 114 unique products. They break down like this; We have 89 olive oils, 18 flavor infused oils and seven bath and beauty products. If you add up all three of these numbers, you'll find that all 114 products are represented in the summary. Now let's see what happens when you add in a where clause to filter some of the products out. The where clause needs to go between the from clause and the group by clause. So come over here and give myself a new blank line on line number eight. If you try and put the where clause somewhere else, then the database engine is…

Contents