Why the following statement is erroneous?
SELECT dept_name, ID, avg (salary)
FROM instructor
GROUP BY dept_name;
a) Dept_id should not be used in group by clause
b) Group by clause is not valid in this query
c) Avg(salary) should not be selected
d) None
Correct option: A
Any property that does not occur in the group by clause must only appear in an aggregate function if it also appears in the select clause; otherwise, the query is considered incorrect.
Thanks for Reading
Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.
Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.