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 Fay's value in the second column? SELECT name, PERCENT_RANK() OVER (ORDER BY sal) FROM Emp;
- A. 5/7
- B. 6/7
- C. 5/6
- D. 1
Correct answer: C. 5/6
PERCENT_RANK = (rank − 1) / (rows − 1). In ascending salary order Fay (75) has rank 6 of 7, so (6 − 1) / (7 − 1) = 5/6. CUME_DIST would give 6/7.
More DBMS and SQL questions
- 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…
- 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…
- 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…
- A B+ tree index uses 2048-byte blocks, 16-byte search keys, 8-byte block pointers and 10-byte record pointers; a leaf also holds one…
- A file of 12,000 blocks is sorted by external merge sort with 25 buffer blocks: the run-creation pass makes runs of 25 blocks, and each…
- Relations R (800 blocks) and S (300 blocks) are joined by block nested-loop join with 52 buffer blocks (one for output, one for the inner…