Bird
0
0

What will be the result of this query?

medium📝 query result Q5 of 15
SQL - GROUP BY and HAVING
What will be the result of this query?

SELECT department, AVG(salary) FROM employees GROUP BY department;
AList of departments without salary info
BAverage salary for each department
CAverage salary for all employees combined
DSyntax error due to missing WHERE clause
Step-by-Step Solution
Solution:
  1. Step 1: Analyze GROUP BY with AVG()

    The query groups employees by department and calculates average salary per group.
  2. Step 2: Understand output meaning

    Each row shows a department and its average salary.
  3. Final Answer:

    Average salary for each department -> Option B
  4. Quick Check:

    GROUP BY department + AVG = average per department [OK]
Quick Trick: AVG with GROUP BY calculates per group average [OK]
Common Mistakes:
MISTAKES
  • Confusing average per group with total average
  • Expecting error without WHERE clause
  • Thinking departments listed without salary

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes