For a column email containing two NULLs among ten rows, what does COUNT(email) return?
Correct answer
C. 8, because NULL values are not counted
15 views
C. 8, because NULL values are not counted
15 views
COUNT(column) counts only non-NULL values, so the two missing entries are excluded and the result is 8. COUNT(*) instead counts rows regardless of content and would return 10, which is why it is the right choice for a total row count. This NULL-skipping behaviour applies to AVG and SUM too, so AVG(email_score) divides by the non-null count rather than by the row count.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.