Bird
0
0

Identify the error in this query:

medium📝 Debug Q6 of 15
SQL - Aggregate Functions
Identify the error in this query:

SELECT Department, SUM(Salary) FROM Employees;
ASalary column does not exist
BSUM() cannot be used with Salary
CSELECT must include COUNT() with SUM()
DMissing GROUP BY clause for Department
Step-by-Step Solution
Solution:
  1. Step 1: Check aggregation with non-aggregated columns

    When selecting Department and SUM(Salary), Department must be grouped.
  2. Step 2: Identify missing GROUP BY

    The query lacks GROUP BY Department, causing an error.
  3. Final Answer:

    Missing GROUP BY clause for Department -> Option D
  4. Quick Check:

    Non-aggregated columns need GROUP BY [OK]
Quick Trick: Use GROUP BY for columns alongside aggregation [OK]
Common Mistakes:
MISTAKES
  • Ignoring GROUP BY when mixing columns and aggregates
  • Thinking SUM() is invalid for numeric columns
  • Assuming COUNT() is always needed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes