CS FundamentalsModerateGATE 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 does this query return? (LIMIT/OFFSET is the SQLite/PostgreSQL/MySQL form of standard OFFSET ... FETCH.) SELECT name FROM Emp ORDER BY sal DESC, name LIMIT 2 OFFSET 2;

  1. A. Fay and Cy
  2. B. Bin and Dev
  3. C. Cy and Dev
  4. D. Cy and Bin

Correct answer: D. Cy and Bin

Sorted by salary descending and then name: Aru 90, Fay 75, Cy 70, Bin 60, Dev 60, Eli 40, Gus 30. Skipping 2 and taking 2 gives Cy and Bin; the name tie-breaker puts Bin before Dev.

More DBMS and SQL questions

Exams that ask this topic