CS FundamentalsHardTCS Digital · Infosys

E(n, dept, sal) holds (a, x, 50), (b, x, 70), (c, x, 60), (d, y, 40), (e, y, 40), (f, z, 90). How many rows does SELECT n FROM E e1 WHERE sal > (SELECT AVG(sal) FROM E e2 WHERE e2.dept = e1.dept) return?

  1. A. 2
  2. B. 3
  3. C. 4
  4. D. 1

Correct answer: D. 1

Averages are x = 60, y = 40, z = 90. Only b (70 > 60) is strictly above its department average; c equals it, and y and z rows are not above.

More DBMS and SQL questions

Exams that ask this topic