
Hello Rishabh, really nice question.
When you use GROUP BY, you’re asking SQL to take many rows and squeeze them into one row per group. In your case, the groups are countries. That means all customers from the same country get combined so you can calculate something about the whole group — like the average age.
Here’s the key idea:
A grouped result needs one clear value per group.
The country has one value, the average age has one value… but the name does not. There are many customer names in each country, so SQL doesn’t know which one to show.
That’s why this works:
SELECT country, AVG(age) AS average_age
FROM Customers
GROUP BY country;
But adding a name does not make sense unless you also group by it or aggregate it. If you tried:
SELECT country, name, AVG(age)
SQL would ask: “Which name should I show for this country? There are many.”
Once you see it that way, it becomes clear:
GROUP BY is for summaries, not individual details.
If you have further questions, I'm here to help.








