Bird
0
0

What does COUNT(column_name) count in SQL?

easy📝 Conceptual Q2 of 15
SQL - Aggregate Functions
What does COUNT(column_name) count in SQL?
AOnly rows where <code>column_name</code> is NOT NULL
BOnly rows where <code>column_name</code> is NULL
CAll rows in the table
DRows where any column is NOT NULL
Step-by-Step Solution
Solution:
  1. Step 1: Understand COUNT(column_name) behavior

    COUNT(column_name) counts only rows where the specified column is NOT NULL.
  2. Step 2: Contrast with COUNT(*)

    Unlike COUNT(*), it ignores rows where the column has NULL values.
  3. Final Answer:

    Only rows where column_name is NOT NULL -> Option A
  4. Quick Check:

    COUNT(column) = counts non-NULL column values [OK]
Quick Trick: COUNT(column) skips NULLs in that column only [OK]
Common Mistakes:
MISTAKES
  • Assuming COUNT(column) counts all rows
  • Confusing NULL and NOT NULL counts
  • Thinking COUNT(column) counts NULLs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes