Problem Statement
In standard SQL, which SELECT list is valid with GROUP BY?
Explanation
Every non-aggregated column in the SELECT list must be functionally dependent on the GROUP BY columns, and practically must be listed there.
If a column is not grouped, aggregate it or remove it from the projection.
Code Solution
SolutionRead Only
SELECT dept_id, COUNT(*) FROM employees GROUP BY dept_id;
Practice Sets
This question appears in the following practice sets:
