Get startedGet started for free

Filter with HAVING

Your final keyword is HAVING. It works similarly to WHERE in that it is a filtering clause, with the difference that HAVING filters grouped data.

Filtering grouped data can be especially handy when working with a large dataset. When working with thousands or even millions of rows, HAVING will allow you to filter for just the group of data you want, such as films over two hours in length!

Practice using HAVING to find out which countries (or country) have the most varied film certifications.

This exercise is part of the course

Intermediate SQL

View Course

Exercise instructions

  • Select country from the films table, and get the distinct count of certification aliased as certification_count.
  • Group the results by country.
  • Filter the unique count of certifications to only results greater than 10.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

-- Select the country and distinct count of certification as certification_count
___
-- Group by country
___
-- Filter results to countries with more than 10 different certifications
___
Edit and Run Code