Bird
0
0

Identify the error in this SQL query:

medium📝 Debug Q6 of 15
SQL - GROUP BY and HAVING
Identify the error in this SQL query:

SELECT department, COUNT(*) FROM employees WHERE department GROUP BY department;
ACOUNT(*) cannot be used with GROUP BY
BGROUP BY should come before WHERE
Cdepartment cannot be selected with GROUP BY
DWHERE clause is missing a condition
Step-by-Step Solution
Solution:
  1. Step 1: Review WHERE clause usage

    WHERE requires a condition to filter rows; 'WHERE department' alone is invalid.
  2. Step 2: Confirm correct clause order

    GROUP BY must come after WHERE, so order is correct.
  3. Final Answer:

    WHERE clause is missing a condition -> Option D
  4. Quick Check:

    WHERE needs condition, not just column name [OK]
Quick Trick: WHERE must have a condition, not just a column [OK]
Common Mistakes:
MISTAKES
  • Using WHERE without condition
  • Placing GROUP BY before WHERE
  • Thinking COUNT(*) is invalid with GROUP BY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes