Bird
0
0

What will be the output of this query on table employees with columns department and salary?

medium📝 query result Q5 of 15
SQL - GROUP BY and HAVING
What will be the output of this query on table employees with columns department and salary?

SELECT department, AVG(salary) FROM employees GROUP BY department;
AAverage salary for each department
BTotal salary for all employees
CList of employees sorted by salary
DCount of employees in each department
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: Determine output meaning

    AVG(salary) returns the average salary for each department group.
  3. Final Answer:

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

    AVG with GROUP BY = average per group [OK]
Quick Trick: AVG with GROUP BY calculates group averages [OK]
Common Mistakes:
MISTAKES
  • Confusing average with total
  • Thinking it lists employees
  • Assuming it counts employees

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes