CS FundamentalsModerateTCS Digital · Infosys SP · 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 region, AVG(amt), COUNT(amt), COUNT(*) FROM Sale WHERE region = 'S' GROUP BY region;
- A. S, 250, 1, 2
- B. S, 250, 2, 2
- C. S, 125, 2, 2
- D. S, 125, 1, 2
Correct answer: A. S, 250, 1, 2
The S group has two rows, one with NULL amt. AVG and COUNT(amt) ignore the NULL (250 and 1); COUNT(*) still counts both rows.
More DBMS and SQL questions
- 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…
- Classify the schedule R3(B), R3(A), W3(A), W1(A), R2(B), W1(B), W2(A), R1(B).
- Table Stu(sid, sname) rows: (1, 'Om'), (2, 'Pia'), (3, 'Raj'), (4, 'Sia'). Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2'…
- Table P(x) rows: (1), (2), (2), (3), (NULL). Table Q(x) rows: (2), (3), (3), (NULL), (4). What does this query return? sql SELECT COUNT()…
- 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…