CS FundamentalsEasyGATE CS (PYQ pattern)

CO(c, n): (a,1), (a,2), (b,3), (b,3), (c,NULL), (c,4). What are COUNT(DISTINCT n), SUM(n), SUM(DISTINCT n) and AVG(n), in that order?

  1. A. 5, 13, 10, 2.6
  2. B. 4, 13, 10, 2.6
  3. C. 4, 16, 10, 2.16667
  4. D. 4, 13, 13, 2.5

Correct answer: B. 4, 13, 10, 2.6

Distinct non-NULL n values are 1, 2, 3, 4 (4 of them, SUM(DISTINCT) = 10). SUM(n) = 13 (3 counted twice, NULL skipped). AVG skips NULL: 13 / 5 = 2.6, not 13 / 6.

More DBMS and SQL questions

Exams that ask this topic