What is AVG(col) over the three values 10, 20 and NULL?
Correct answer
C. 15, because the NULL is excluded from both the sum and the count
15 views
C. 15, because the NULL is excluded from both the sum and the count
15 views
Aggregate NULL handling: most aggregates ignore NULL inputs, so AVG computes 30 divided by 2 and returns 15 rather than 10. Treating NULL as zero would be AVG(COALESCE(col, 0)) = 10, a different and often wrong question. SUM over only NULLs returns NULL, while COUNT returns 0.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.