Bird
0
0

What does the SQL function COUNT(*) do when used with GROUP BY?

easy📝 Conceptual Q2 of 15
SQL - Advanced Query Patterns
What does the SQL function COUNT(*) do when used with GROUP BY?
ACounts the number of distinct groups
BCounts the number of rows in each group
CCounts the total rows in the table
DCounts only NULL values
Step-by-Step Solution
Solution:
  1. Step 1: Understand COUNT(*) function

    COUNT(*) counts all rows, including duplicates and NULLs, in the current context.
  2. Step 2: Effect with GROUP BY

    When used with GROUP BY, COUNT(*) returns the number of rows in each group separately.
  3. Final Answer:

    Counts the number of rows in each group -> Option B
  4. Quick Check:

    COUNT(*) with GROUP BY = rows per group [OK]
Quick Trick: COUNT(*) counts all rows in each group, including duplicates [OK]
Common Mistakes:
  • Thinking COUNT(*) counts distinct groups
  • Assuming it counts only non-NULL values
  • Confusing with COUNT(column_name)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes