0
0
SQLquery~5 mins

NULL behavior in aggregate functions in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What happens to NULL values when using the COUNT(column) aggregate function?
COUNT(column) ignores NULL values and counts only non-NULL entries in that column.
Click to reveal answer
beginner
How do aggregate functions like SUM, AVG, MIN, and MAX treat NULL values?
They ignore NULL values and perform calculations only on non-NULL values.
Click to reveal answer
intermediate
What is the result of SUM() or AVG() if all values in the column are NULL?
The result is NULL because there are no non-NULL values to calculate.
Click to reveal answer
beginner
Does COUNT(*) ignore NULL values?
No, COUNT(*) counts all rows, including those with NULL values in any column.
Click to reveal answer
intermediate
Why is it important to understand NULL behavior in aggregate functions?
Because NULLs can affect the results of queries, leading to unexpected counts or calculations if not handled properly.
Click to reveal answer
Which aggregate function counts all rows, including those with NULL values?
ACOUNT(column)
BAVG(column)
CSUM(column)
DCOUNT(*)
If a column has values (10, NULL, 20), what does SUM(column) return?
A30
BNULL
C10
D20
What does AVG(column) return if all values are NULL?
A0
BError
CNULL
D1
Which aggregate function ignores NULL values when counting?
ACOUNT(column)
BCOUNT(NULL)
CCOUNT(1)
DCOUNT(*)
MIN(column) with values (NULL, 5, 3) returns:
ANULL
B3
C5
DError
Explain how NULL values affect the results of COUNT(column) and COUNT(*).
Think about whether NULLs are included or excluded in each count.
You got /3 concepts.
    Describe what happens when aggregate functions like SUM or AVG operate on columns with NULL values.
    Consider how NULLs affect the calculation and final output.
    You got /3 concepts.