CS FundamentalsModerateTCS 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 SUM(CASE WHEN pay >= 55 THEN 1 ELSE 0 END),
SUM(CASE WHEN pay < 55 THEN 1 ELSE 0 END)
FROM Staff;- A. 3, 2
- B. 3, 3
- C. 3, 2, 1
- D. 4, 2
Correct answer: A. 3, 2
Bala, Chitra, Farid have pay ≥ 55; Anu and Esha are below. Dev's NULL makes both conditions UNKNOWN, so both CASEs fall to ELSE 0 — his row is counted in neither.
More DBMS and SQL questions
- R(A, B, C, D, E) with functional dependencies AB → C, BD → CE, A → B is decomposed into R1(C, D), R2(A, B, E). Which statement is correct?
- A fuzzy checkpoint differs from a simple (quiescent) checkpoint because it:
- Table Dept(did PRIMARY KEY) rows: (10), (20), (30). Table Emp(eid PRIMARY KEY, did REFERENCES Dept(did) ON DELETE CASCADE, mentor…
- Classify the schedule W3(A), R1(A), R2(B), R2(A), R3(B), C2, W1(B), R1(B), C1, C3 (Ci = commit of Ti) by the strongest property it…
- R(A, B) has 120 tuples and S(B, C) has 40 tuples, where B is a key of neither relation. What are the minimum and maximum possible numbers…
- R(A, B, C, D, E) has functional dependencies D → A, AB → CD, BE → C, BC → E. What is the closure {BC}⁺?