CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ

Table Emp(eid, name, mgr, dept, sal) rows: (1, 'Aru', NULL, 'D1', 90), (2, 'Bin', 1, 'D1', 60), (3, 'Cy', 1, 'D2', 70), (4, 'Dev', 2, 'D1', 60), (5, 'Eli', 2, 'D2', 40), (6, 'Fay', 3, NULL, 75), (7, 'Gus', 4, 'D1', 30). mgr refers to eid. This statement is run: DELETE FROM Emp WHERE sal < (SELECT AVG(sal) FROM Emp); How many rows remain, and what is their salary total?

  1. A. 4 rows totalling 295
  2. B. 2 rows totalling 165
  3. C. 3 rows totalling 235
  4. D. 3 rows totalling 225

Correct answer: C. 3 rows totalling 235

The average is 425 / 7 ≈ 60.71, computed once before any row is deleted. Bin, Dev (60), Eli (40) and Gus (30) go, leaving Aru, Cy and Fay: 90 + 70 + 75 = 235.

More DBMS and SQL questions

Exams that ask this topic