Erroneous statement-Quiz question based on DBMS

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.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store