Recall & Review
beginner
What happens to NULL values when using GROUP BY in SQL?
NULL values are grouped together as a single group in the result set.
Click to reveal answer
beginner
Can GROUP BY distinguish between different NULL values?
No, all NULL values are treated as equal and grouped into one group.
Click to reveal answer
intermediate
How does GROUP BY handle columns with NULL values in aggregation?
GROUP BY treats all NULLs as one group, so aggregate functions like COUNT or SUM apply to that group as a whole.
Click to reveal answer
intermediate
Why is it important to know how NULLs behave in GROUP BY?
Because NULLs can affect the number of groups and the results of aggregate functions, impacting query results and analysis.
Click to reveal answer
beginner
Write a simple SQL query that groups rows by a column that contains NULL values.
SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name;
Click to reveal answer
When using GROUP BY on a column with NULL values, how are the NULLs treated?
✗ Incorrect
In SQL, all NULL values in a GROUP BY column are grouped together as a single group.
If a column has three NULL values and two non-NULL values, how many groups will GROUP BY create?
✗ Incorrect
GROUP BY groups all NULLs together as one group plus each distinct non-NULL value forms its own group, so total groups = 1 (NULL group) + 2 (non-NULL values) = 3 groups.
Which aggregate function counts NULL values in a GROUP BY group?
✗ Incorrect
COUNT(*) counts all rows including those with NULLs, while COUNT(column_name) ignores NULLs.
What is the result of grouping by a column where all values are NULL?
✗ Incorrect
All NULL values are grouped together, so one group containing all rows is created.
Does GROUP BY treat NULL as equal to any other value?
✗ Incorrect
GROUP BY treats all NULLs as equal to each other, grouping them into one group.
Explain how SQL GROUP BY handles NULL values in a column.
Think about how NULLs are treated as equal or different in grouping.
You got /4 concepts.
Describe a scenario where understanding GROUP BY behavior with NULLs is important.
Consider reports or summaries with incomplete data.
You got /4 concepts.