CS FundamentalsHardAmazon/Flipkart SQL round · GATE CS
Table P(x) rows: (1), (2), (2), (3), (NULL). Table Q(x) rows: (2), (3), (3), (NULL), (4). What does this query return?
Table P(x) rows: (1), (2), (2), (3), (NULL).
Table Q(x) rows: (2), (3), (3), (NULL), (4).
What does this query return?
SELECT COUNT(*) FROM P WHERE NOT EXISTS (SELECT * FROM Q WHERE Q.x = P.x);
- A. 3
- B. 2
- C. 1
- D. 0
Correct answer: B. 2
NOT EXISTS is two-valued: P's 1 has no match and P's NULL matches nothing (NULL = anything is unknown), so both rows qualify: 2. Contrast with NOT IN, which returns 0 here.
More DBMS and SQL questions
- R(A, B, C, D, E) has the set of functional dependencies Σ = {E → BD, AE → C, C → AD}. Which of the following FDs is NOT in Σ⁺ (not implied…
- In a B+ tree every internal node can have at most 50 children and every leaf can hold at most 40 keys. With exactly 3 levels (root at…
- TS(T1) = 15, TS(T2) = 30, TS(T3) = 25; all read/write timestamps start at 0. Under basic timestamp ordering with Thomas's write rule…
- R(A, B, C, D, E) with functional dependencies B → AD, AC → B, A → B is decomposed into R1(A, B), R2(B, D), R3(B, C, E). Which statement is…
- R(A, B, C, D, E, F) has functional dependencies A → CD, CF → A, E → B, D → A. Which of these attribute sets is NOT a superkey of R?
- 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…