CS FundamentalsModerateTCS Digital · Infosys SP · GATE CS

Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2', NULL), (2, 'C1', 65), (3, 'C2', 90), (3, 'C3', 75), (5, 'C1', 50). What does this query return?

Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2', NULL), (2, 'C1', 65), (3, 'C2', 90), (3, 'C3', 75), (5, 'C1', 50). What does this query return?
SELECT AVG(c) FROM (SELECT COUNT(*) AS c FROM Takes GROUP BY sid);
  1. A. 1.2
  2. B. 1.5
  3. C. 1.25
  4. D. 2

Correct answer: B. 1.5

Courses per sid: 1 → 2, 2 → 1, 3 → 2, 5 → 1. The average of these four counts is 6/4 = 1.5.

More DBMS and SQL questions

Exams that ask this topic