CS FundamentalsHardGATE CS · SQL
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 e.name FROM Staff e JOIN Staff b ON e.boss = b.id WHERE e.pay > b.pay ORDER BY e.name;
- A. Chitra, Farid
- B. Bala, Chitra, Farid
- C. Bala, Chitra
- D. Bala, Chitra, Dev, Farid
Correct answer: B. Bala, Chitra, Farid
Compare each employee with their boss: Bala 55 > Anu 40, Chitra 70 > 40, Farid 70 > Bala 55. Dev's pay is NULL (comparison unknown) and Esha 35 < Chitra 70.
More DBMS and SQL questions
- R(A, B, C, D, E) has functional dependencies B → AC, C → B, AC → B, A → B. How many prime attributes does R have?
- Table Stu(sid, sname) rows: (1, 'Om'), (2, 'Pia'), (3, 'Raj'), (4, 'Sia'). Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2'…
- A B+ tree index uses 4096-byte blocks, 20-byte search keys, 12-byte block (tree) pointers and 14-byte record pointers. What is the maximum…
- For the schedule W1(C), W2(C), R2(B), R3(A), W4(C), R4(C), R3(B), R1(B), how many serial schedules of T1–T4 are conflict-equivalent to it?
- Extendible hashing uses the LOWEST-order bits of a key's binary value, bucket capacity 2, and starts with global depth 0 and one empty…
- R(A, B, C, D, E) has functional dependencies C → E, AC → DE, E → D, BC → DE, AD → CE. How many prime attributes does R have?