CS FundamentalsModerateProduct placement · SQL round
Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4, 'Dev', 'Tech', NULL, 3), (5, 'Esha', NULL, 35, 3), (6, 'Farid', 'Tech', 70, 2). What does this query return?
Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4, 'Dev', 'Tech', NULL, 3), (5, 'Esha', NULL, 35, 3), (6, 'Farid', 'Tech', 70, 2).
What does this query return?
SELECT MAX(pay) FROM Staff WHERE pay < (SELECT MAX(pay) FROM Staff);
- A. 70
- B. 55
- C. NULL
- D. 40
Correct answer: B. 55
The inner MAX is 70 (two people earn it). The largest pay strictly below 70 is 55 — the second-highest DISTINCT pay.
More DBMS and SQL questions
- R(A, B, C, D, E) has functional dependencies CE → A, A → CE, BE → A, BC → E, E → BC. What is the highest normal form R satisfies?
- A transaction has executed its final statement, but its commit record is not yet on stable storage. Which state is it in?
- R(A, B, C, D, E, F) has functional dependencies EF → D, B → C, D → BF, A → E. How many superkeys does R have?
- Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5). What does this…
- R(A, B, C, D, E) with functional dependencies E → BC, D → B is decomposed into R1(A, B, D), R2(C, D), R3(B, C, E). Which statement is…
- A B+ tree index uses 1024-byte blocks, 12-byte search keys, 10-byte block pointers and 6-byte record (data) pointers. Each leaf also keeps…