Project: Only Keep Interesting Groups

Practice filtering grouped results using HAVING.

Task

Write a query that:

  • Groups people by city.

  • Calculates the average age for each city.

  • Shows only the cities where the average age is less than 28.

  • Displays the city name and the average age (use an alias like avg_age).

Tables

Here is the people and pets table that you’ll use:

The people table

Get hands-on with 1400+ tech skills courses.