Search⌘ K
AI Features

Solution: Only Keep Interesting Groups

Explore filtering grouped data in SQL by using the HAVING clause to keep only interesting groups. Learn how to calculate averages per city and display results that meet specific aggregate conditions in your queries.

Query

SELECT city, AVG(age) AS avg_age
FROM people
GROUP BY city
HAVING AVG(age) < 28;
...