Bird
0
0

What does the SQL aggregate function COUNT(column_name) do when the column contains NULL values?

easy📝 Conceptual Q1 of 15
SQL - Aggregate Functions
What does the SQL aggregate function COUNT(column_name) do when the column contains NULL values?
ACounts all rows including those with NULL values
BReturns NULL if any NULL values exist in the column
CCounts only the rows where the column is NULL
DCounts only the rows where the column is NOT NULL
Step-by-Step Solution
Solution:
  1. Step 1: Understand COUNT behavior with NULLs

    The COUNT(column_name) function counts only non-NULL values in that column.
  2. Step 2: Compare options with this behavior

    Counts only the rows where the column is NOT NULL correctly states it counts only rows where the column is NOT NULL.
  3. Final Answer:

    Counts only the rows where the column is NOT NULL -> Option D
  4. Quick Check:

    COUNT(column_name) excludes NULLs = B [OK]
Quick Trick: COUNT(column) ignores NULLs, counts only non-NULL values [OK]
Common Mistakes:
MISTAKES
  • Thinking COUNT counts NULLs
  • Assuming COUNT returns NULL if NULLs exist
  • Confusing COUNT(*) with COUNT(column)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes