Find the Aggregation Mistake
Find the Mistake Medium
Question
This query has a logical error. Find and fix it:
Code
SELECT name, AVG(price) FROM products;
Hint
AVG collapses all rows into one — what happens to name?
Explanation
This query mixes a non-aggregated column (name) with an aggregate function (AVG(price)) without GROUP BY. The database does not know which name to show for the single averaged row. Fix: either add GROUP BY name, or remove name from SELECT.
Related Resources
Related Lessons
- Aggregations
Learn aggregation rules.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.