CS FundamentalsVery hardGoogle/Microsoft SDE · GATE CS

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 is Bin's value in the second column? SELECT name, CUME_DIST() OVER (ORDER BY sal) FROM Emp;

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

Correct answer: B. 4/7

CUME_DIST counts the rows with salary ≤ the current one, peers included, over the total. Bin's 60 ties with Dev, so 30, 40, 60, 60 give 4/7 for both of them.

More DBMS and SQL questions

Exams that ask this topic