Bird
0
0

Which of the following is the correct syntax to count only non-NULL values in the column age from the table persons?

easy📝 Syntax Q12 of 15
SQL - Aggregate Functions
Which of the following is the correct syntax to count only non-NULL values in the column age from the table persons?
ASELECT COUNT(*) FROM persons;
BSELECT COUNT(age) FROM persons;
CSELECT COUNT(DISTINCT age) FROM persons;
DSELECT COUNT(age IS NOT NULL) FROM persons;
Step-by-Step Solution
Solution:
  1. Step 1: Identify how to count non-NULL values

    COUNT(column) counts only non-NULL values in that column.
  2. Step 2: Check syntax correctness

    SELECT COUNT(age) FROM persons; correctly counts non-NULL age values.
  3. Final Answer:

    SELECT COUNT(age) FROM persons; -> Option B
  4. Quick Check:

    COUNT(column) counts non-NULL values [OK]
Quick Trick: Use COUNT(column) to count non-NULL values [OK]
Common Mistakes:
MISTAKES
  • Using COUNT(*) to count non-NULL values
  • Using WHERE clause unnecessarily
  • Using COUNT with boolean expressions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes