Bird
0
0

If a table sales has 10 rows and the discount column has 4 NULLs, what does SELECT COUNT(*) - COUNT(discount) FROM sales; return?

medium📝 query result Q5 of 15
SQL - Aggregate Functions
If a table sales has 10 rows and the discount column has 4 NULLs, what does SELECT COUNT(*) - COUNT(discount) FROM sales; return?
A6
B10
C4
D0
Step-by-Step Solution
Solution:
  1. Step 1: Understand the expressions

    COUNT(*) counts all 10 rows; COUNT(discount) counts only non-NULL discount rows (10 - 4 = 6).
  2. Step 2: Calculate the difference

    COUNT(*) - COUNT(discount) = 10 - 6 = 4, which equals the number of NULL discount values.
  3. Final Answer:

    4 -> Option C
  4. Quick Check:

    Difference = number of NULLs in discount [OK]
Quick Trick: COUNT(*) - COUNT(column) = number of NULLs in that column [OK]
Common Mistakes:
MISTAKES
  • Mixing up which count excludes NULLs
  • Assuming difference equals non-NULL count
  • Calculating wrong subtraction order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes