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. What values does the third column show for Cy and Aru? SELECT name, sal, SUM(sal) OVER (ORDER BY sal ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM Emp;

  1. A. 205 and 165
  2. B. 205 and 235
  3. C. 190 and 165
  4. D. 235 and 165

Correct answer: A. 205 and 165

In salary order (30, 40, 60, 60, 70, 75, 90) Cy's frame is 60 + 70 + 75 = 205. Aru is last, so his frame has no following row: 75 + 90 = 165.

More DBMS and SQL questions

Exams that ask this topic