Bird
0
0

Given the table employees with columns department and salary, what does this query return?

medium📝 query result Q4 of 15
SQL - Aggregate Functions
Given the table employees with columns department and salary, what does this query return?
SELECT department, COUNT(*), AVG(salary) FROM employees GROUP BY department;
AList of departments without any aggregation
BTotal salary and employee count for all departments combined
CNumber of employees and average salary per department
DSyntax error due to missing WHERE clause
Step-by-Step Solution
Solution:
  1. Step 1: Analyze GROUP BY usage

    GROUP BY department groups rows by department for aggregation.
  2. Step 2: Understand aggregates COUNT and AVG

    COUNT(*) counts employees per department; AVG(salary) calculates average salary per department.
  3. Final Answer:

    Number of employees and average salary per department -> Option C
  4. Quick Check:

    GROUP BY + COUNT + AVG = grouped summaries [OK]
Quick Trick: GROUP BY groups rows; aggregates summarize per group [OK]
Common Mistakes:
MISTAKES
  • Thinking aggregates apply to whole table without grouping
  • Expecting list without aggregation
  • Assuming WHERE is mandatory here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes