How to tackle 'error: column is not contained in an aggregate function or group by' in sql?
This error is a result of having columns in the SELECT clause that aren't included in a GROUP BY clause or aren't used in an aggregate function.
Example:
SELECT name, age, COUNT(*) FROM users GROUP BY name;
Solution:
SELECT name, COUNT(*) FROM users GROUP BY name; -- removed 'age' from SELECT
Every column in the SELECT clause that isn't used with an aggregate function should be listed in the GROUP BY clause.