Bird
0
0

Identify the error in this query: SELECT COUNT(column_name) FROM table_name WHERE column_name = NULL;

medium📝 Debug Q6 of 15
SQL - Aggregate Functions
Identify the error in this query: SELECT COUNT(column_name) FROM table_name WHERE column_name = NULL;
AIncorrect NULL comparison with '=' operator
BUsing COUNT(column_name) instead of COUNT(*)
CMissing GROUP BY clause
DCOUNT cannot be used with WHERE clause
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the WHERE clause

    In SQL, NULL cannot be compared using '='; use IS NULL instead.
  2. Step 2: Check COUNT usage

    COUNT(column_name) is valid; WHERE clause is allowed; no GROUP BY needed here.
  3. Final Answer:

    Incorrect NULL comparison with '=' operator -> Option A
  4. Quick Check:

    Use IS NULL, not = NULL [OK]
Quick Trick: Use IS NULL to check NULL values, not '=' [OK]
Common Mistakes:
MISTAKES
  • Using '=' to compare NULL
  • Thinking COUNT can't be used with WHERE
  • Confusing COUNT(*) and COUNT(column)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes