Bird
0
0

What does the SQL function COUNT(column_name) return when used in a query?

easy📝 Conceptual Q1 of 15
SQL - Aggregate Functions
What does the SQL function COUNT(column_name) return when used in a query?
AThe total number of rows in the table
BThe number of non-NULL values in the specified column
CThe sum of all values in the specified column
DThe number of NULL values in the specified column
Step-by-Step Solution
Solution:
  1. Step 1: Understand COUNT(column_name) behavior

    COUNT(column_name) counts only rows where the column value is NOT NULL.
  2. Step 2: Differentiate from COUNT(*)

    COUNT(*) counts all rows regardless of NULLs, but COUNT(column_name) excludes NULLs.
  3. Final Answer:

    The number of non-NULL values in the specified column -> Option B
  4. Quick Check:

    COUNT(column_name) = non-NULL count [OK]
Quick Trick: COUNT(column) ignores NULLs, COUNT(*) counts all rows [OK]
Common Mistakes:
MISTAKES
  • Confusing COUNT(column) with COUNT(*)
  • Thinking COUNT(column) counts NULLs
  • Assuming COUNT(column) sums values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes