CS FundamentalsHardGATE CS (PYQ pattern)
G(g, x): (a,5), (a,7), (b,4), (b,4), (b,4), (c,20), (d,NULL), (d,1). How many groups does SELECT g FROM G GROUP BY g HAVING SUM(x) > (SELECT AVG(s) FROM (SELECT SUM(x) AS s FROM G GROUP BY g)) return?
- A. 4
- B. 5
- C. 0
- D. 3
Correct answer: D. 3
Group sums are a = 12, b = 12, c = 20, d = 1; their average is 11.25. Groups with a sum above 11.25: a (12), b (12) and c (20), so 3 groups; d (1) is below.
More DBMS and SQL questions
- SALE(r, q, amt): (n,1,10), (n,2,30), (s,1,5), (s,2,5), (s,3,5), (e,1,50). View V is SELECT r, SUM(amt) AS tot, COUNT() AS c FROM SALE…
- A Grace hash join partitions both inputs into B - 1 partitions using one input page per partition plus one input buffer; in the probe…
- A table has 1,000,000 rows in 10,000 pages. An unclustered B+ tree index of height 3 costs 3 page reads to reach the first matching entry…
- A RAID 6 array has 10 disks, each sustaining 200 random I/Os per second. A small read costs 1 disk I/O and a small write costs 6 (read…
- Which of the following tuple-relational-calculus expressions are SAFE (guaranteed to return a finite result for every database)? I. { t |…
- R(A, B) = {(1,a), (1,b), (2,a), (3,c), (4,a), (5,b), (5,c)} and S(B) is EMPTY. Using the standard definition R ÷ S = πA(R) − πA((πA(R) ×…