Bird
0
0

You have a table products with 100 rows. The price column has 10 NULLs and the stock column has 5 NULLs. What does this query return?

hard📝 Application Q8 of 15
SQL - Aggregate Functions
You have a table products with 100 rows. The price column has 10 NULLs and the stock column has 5 NULLs. What does this query return?
SELECT COUNT(*) AS total_rows, COUNT(price) AS price_count, COUNT(stock) AS stock_count FROM products;
Atotal_rows=100, price_count=100, stock_count=100
Btotal_rows=95, price_count=90, stock_count=95
Ctotal_rows=100, price_count=90, stock_count=95
Dtotal_rows=90, price_count=90, stock_count=95
Step-by-Step Solution
Solution:
  1. Step 1: Understand COUNT(*)

    COUNT(*) counts all rows: 100.
  2. Step 2: Calculate COUNT(price)

    price has 10 NULLs, so count is 100 - 10 = 90.
  3. Step 3: Calculate COUNT(stock)

    stock has 5 NULLs, so count is 100 - 5 = 95.
  4. Final Answer:

    total_rows=100, price_count=90, stock_count=95 -> Option C
  5. Quick Check:

    COUNT(*) counts all; COUNT(column) excludes NULLs [OK]
Quick Trick: COUNT(*) counts all rows; COUNT(column) excludes NULLs [OK]
Common Mistakes:
MISTAKES
  • Subtracting NULLs incorrectly
  • Assuming COUNT(column) counts NULLs
  • Mixing total rows with column counts

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes