Bird
0
0

What is wrong with this query?

medium📝 Debug Q7 of 15
SQL - Aggregate Functions
What is wrong with this query?

SELECT AVG(Salary), Department FROM Employees GROUP BY Department;
AColumn order in SELECT is incorrect
BAVG() cannot be used with GROUP BY
CDepartment must be inside AVG()
DNo error; query is correct
Step-by-Step Solution
Solution:
  1. Step 1: Review aggregation with GROUP BY

    AVG(Salary) calculates average salary per Department grouped correctly.
  2. Step 2: Confirm syntax and logic

    SELECT columns and GROUP BY match; query is valid and returns averages per department.
  3. Final Answer:

    No error; query is correct -> Option D
  4. Quick Check:

    AVG() with GROUP BY is valid [OK]
Quick Trick: AVG() works fine with GROUP BY columns [OK]
Common Mistakes:
MISTAKES
  • Thinking column order matters for correctness
  • Believing aggregation can't be combined with GROUP BY
  • Misunderstanding aggregate function usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes