Bird
0
0

Given the table products with 5 rows where the price column has values: [10, NULL, 20, NULL, 30], what will the query SELECT COUNT(price) FROM products; return?

medium📝 query result Q4 of 15
SQL - Aggregate Functions
Given the table products with 5 rows where the price column has values: [10, NULL, 20, NULL, 30], what will the query SELECT COUNT(price) FROM products; return?
A5
B3
C2
D0
Step-by-Step Solution
Solution:
  1. Step 1: Understand COUNT(column) counts non-NULL values

    Only values 10, 20, and 30 are counted; NULLs are ignored.
  2. Step 2: Count non-NULL values in price column

    There are 3 non-NULL values out of 5 rows.
  3. Final Answer:

    3 -> Option B
  4. Quick Check:

    COUNT(column) excludes NULLs [OK]
Quick Trick: COUNT(column) counts only non-NULL values [OK]
Common Mistakes:
MISTAKES
  • Counting NULLs as values
  • Confusing COUNT(*) with COUNT(column)
  • Assuming COUNT(column) counts all rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes