...

/

Solution: Ask Questions About Questions

Solution: Ask Questions About Questions

We'll cover the following...

Query

SELECT type, AVG(age) AS avg_age
FROM pets
GROUP BY type
HAVING AVG(age) > (
SELECT AVG(age)
FROM pets
);

Explanation

This query finds which types of pets have an average age greater than the overall average age of all pets.

Let’s break it down step by ...