CS FundamentalsVery hardTCS Digital · Infosys SP · GATE CS
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 name FROM Staff s
WHERE pay > (SELECT AVG(pay) FROM Staff t
WHERE t.dept = s.dept);- A. Bala, Esha
- B. Bala, Chitra, Farid
- C. Bala
- D. Chitra, Farid
Correct answer: C. Bala
Ops average = 47.5, so Bala (55) qualifies. Tech average ignores Dev's NULL: (70 + 70)/2 = 70, and nobody exceeds it. For Esha, t.dept = NULL matches nothing, the average is NULL and the comparison is unknown.
More DBMS and SQL questions
- TS(T1) = 20, TS(T2) = 5, TS(T3) = 25; all read/write timestamps start at 0. Under basic timestamp ordering with Thomas's write rule, which…
- R(A, B, C, D, E, F) has functional dependencies D → BF, AE → B, F → CD, DE → C. How many prime attributes does R have?
- R(A, B, C, D, E) has the set of functional dependencies Σ = {CE → D, C → AD, AE → CD}. Which of the following FDs is NOT in Σ⁺ (not…
- R(A, B, C, D) has functional dependencies D → BC, B → C, C → BD. What is the highest normal form R satisfies?
- Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4…
- R(A, B, C, D, E, F) has functional dependencies AE → BC, B → F, E → C, BD → E, F → E. Which of the following is the complete set of…