1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. A table has 10 rows and the column col is NULL in 3 of…

Added 30 Nov -0001

A table has 10 rows and the column col is NULL in 3 of them. What do COUNT(*) and COUNT(col) return?

  1. 10 and 7 Correct answer
  2. 7 and 7
  3. 10 and 10
  4. 7 and 10

Correct answer

A. 10 and 7

19 views

MCQSEXAM

Explanation

COUNT semantics: COUNT(*) counts rows, while COUNT(col) counts only non-NULL values of that column, so three NULLs reduce the second result to 7. The same NULL elimination affects AVG and SUM, where NULLs are skipped rather than treated as zero. COUNT(DISTINCT col) goes further and also removes duplicates among the non-NULL values.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? 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