1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. A column score holds 100, 80 and NULL. What does…

Added 30 Nov -0001

A column score holds 100, 80 and NULL. What does AVG(score) return?

  1. 93.33, because the denominator includes the NULL row
  2. NULL, because any NULL makes the average unknown
  3. 90, because the NULL row is ignored in both parts Correct answer
  4. 60, because NULL is counted as zero

Correct answer

C. 90, because the NULL row is ignored in both parts

17 views

MCQSEXAM

Explanation

Aggregate functions skip NULL inputs entirely, so the sum is 180 and the divisor is the two non-null rows, giving 90 rather than the 60 you would get by treating the missing score as zero. This is why AVG(score) and SUM(score)/COUNT(*) disagree when NULLs are present, since COUNT(*) includes the missing row. Use COALESCE(score, 0) first if the missing values genuinely should count as zero.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More SQL for Data Analysis MCQs

Practise all SQL for Data Analysis MCQs

Similar MCQs