Bird
0
0

If a table has a column with some NULL values and you run SELECT col, COUNT(*) FROM table GROUP BY col;, how many groups will the NULL values form?

easy📝 Conceptual Q2 of 15
SQL - GROUP BY and HAVING
If a table has a column with some NULL values and you run SELECT col, COUNT(*) FROM table GROUP BY col;, how many groups will the NULL values form?
ANo group, NULLs are excluded
BOne group containing all NULL values
CMultiple groups, one for each NULL
DTwo groups, one for NULL and one for non-NULL
Step-by-Step Solution
Solution:
  1. Step 1: Analyze GROUP BY with COUNT and NULL

    COUNT(*) counts all rows, and GROUP BY treats all NULLs as one group.
  2. Step 2: Determine number of groups for NULL

    All NULL values in the column form a single group in the result.
  3. Final Answer:

    One group containing all NULL values -> Option B
  4. Quick Check:

    GROUP BY NULL forms one group [OK]
Quick Trick: COUNT(*) counts all rows including NULL groups [OK]
Common Mistakes:
MISTAKES
  • Assuming NULLs are excluded from COUNT
  • Thinking NULLs form multiple groups
  • Believing NULLs cause errors in GROUP BY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes