Search⌘ K
AI Features

Solution: Ask Questions About Questions

Explore how to improve your SQL queries by asking better questions using grouping and aggregation techniques. Understand how to use subqueries to compare averages and filter grouped data. This lesson guides you through analyzing pet age data to identify types exceeding average age, enhancing your ability to summarize and extract meaningful information from databases.

Query

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

Explanation

...