CS FundamentalsHardGATE CS (PYQ pattern)
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 GROUP BY r. What does SELECT SUM(tot) FROM V WHERE c >= 2 return, and what does SELECT AVG(tot) FROM V return?
- A. 55 and 35
- B. 105 and 35
- C. 55 and 17.5
- D. 55 and 45
Correct answer: A. 55 and 35
V has three rows: n = (40, 2), s = (15, 3), e = (50, 1). Rows with c >= 2 are n and s: 40 + 15 = 55. AVG over the view's three rows is 105 / 3 = 35, not the average over the six SALE rows (17.5).
More DBMS and SQL questions
- 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) ×…
- An ER design has three strong entity sets, one weak entity set (identified through one of them), one multivalued attribute on a strong…