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.
We'll cover the following...
We'll cover the following...
Query
SELECT type, AVG(age) AS avg_ageFROM petsGROUP BY typeHAVING AVG(age) > (SELECT AVG(age)FROM pets);