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 COUNT(*) FROM Staff WHERE dept <> 'Ops';
- A. 2
- B. 4
- C. 6
- D. 3
Correct answer: D. 3
Chitra, Dev and Farid are in Tech. Esha's dept is NULL, and NULL <> 'Ops' is UNKNOWN, so her row is filtered out: 3, not 4.
More DBMS and SQL questions
- Table Sale(id, rep, region, amt) rows: (1, 'Ira', 'N', 100), (2, 'Jai', 'S', 250), (3, 'Ira', 'S', NULL), (4, 'Kim', 'N', 300), (5, 'Jai'…
- Consider the schedule R2(B), R3(A), W3(A), R2(A), W2(B), R1(B), R1(A). Which statement is correct?
- The system crashes after the last record of this log (immediate database modification; <Ti, X> denotes an update with old and new values…
- R(A, B, C, D, E) has functional dependencies CE → A, B → AC, BE → CD, DE → B. How many superkeys does R have?
- Classify the schedule W1(B), W2(A), R2(B), C2, W1(A), C1 (Ci = commit of Ti) by the strongest property it satisfies.
- R(A, B, C, D, E) has functional dependencies CE → A, A → D, AC → DE, B → D. How many superkeys does R have?