CS FundamentalsModerateAmazon/Flipkart SQL round · GATE CS
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', 'N', 150), (6, 'Ira', 'N', 200), (7, 'Lal', NULL, 120). What does this query return?
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', 'N', 150), (6, 'Ira', 'N', 200), (7, 'Lal', NULL, 120).
What does this query return?
SELECT COUNT(DISTINCT rep) FROM Sale WHERE region = 'N' AND rep IN (SELECT rep FROM Sale WHERE region = 'S');
- A. 2
- B. 3
- C. 1
- D. 4
Correct answer: A. 2
N reps: Ira, Kim, Jai, Ira; of these, Ira and Jai also appear in S. DISTINCT counts them once each: 2.
More DBMS and SQL questions
- R(A, B) has 8 tuples. What is the number of tuples in R ⋈ R (natural join of R with itself), and in R × ρ{S(C, D)}(R)?
- R(A, B, C, D, E, F) has FDs B → AC, E → F, EF → BD, F → E. Each option is a relation schema obtained by projecting R, with the…
- On R(A, B, C, D, E), F = {D → A, B → AE} and G = {BE → A, D → A, B → E}. Which statement is correct? ("F covers G" means every FD of G is…
- 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'…
- A multilevel index is built over a first level of 250,000 index entries; every index block holds 68 entries (fan-out 68), and levels are…
- TS(T1) = 10, TS(T2) = 25, TS(T3) = 20; all read/write timestamps start at 0. Under basic timestamp ordering (no Thomas write rule), which…