Bird
0
0

Consider the table employees with columns department and salary. What does this query return?

medium📝 query result Q5 of 15
SQL - GROUP BY and HAVING
Consider the table employees with columns department and salary. What does this query return?

SELECT department, AVG(salary) FROM employees GROUP BY department;
AAverage salary for all employees combined
BList of all employees with their salaries
CAverage salary for each department
DError because AVG cannot be used with GROUP BY
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the query

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

    It returns one row per department with the average salary.
  3. Final Answer:

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

    GROUP BY with AVG returns averages per group = B [OK]
Quick Trick: AVG with GROUP BY calculates per group average [OK]
Common Mistakes:
MISTAKES
  • Expecting average of all salaries without grouping
  • Thinking AVG causes error with GROUP BY
  • Confusing output with full employee list

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes