Multiple choice technology programming languages

A table has following 2 columns with the given valuesc1 c2 -------------- 1 1 1 NULL 2 0 NULL NULL . What will be the output of the following query :select count(*) , count (c1+c2) , count (distinct (c1 + c2)) from temp;

  1. 3,2,1

  2. 3,2,2

  3. 4,2,1

  4. 4,3,2

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

COUNT() counts all rows = 4. COUNT(c1+c2) counts non-null results - NULL+anything=NULL, and 2+0=2, 1+1=2, so only 2 rows have non-null sums. COUNT(DISTINCT(c1+c2)) counts distinct non-null values - both sums equal 2, so only 1 distinct value. Note: the row with NULL NULL is counted in COUNT() but not in the expression counts.