CS FundamentalsHardTCS Digital · Infosys
E(n, dept, sal) holds (a, x, 50), (b, x, 70), (c, x, 60), (d, y, 40), (e, y, 40), (f, z, 90). How many rows does SELECT n FROM E e1 WHERE sal > (SELECT AVG(sal) FROM E e2 WHERE e2.dept = e1.dept) return?
- A. 2
- B. 3
- C. 4
- D. 1
Correct answer: D. 1
Averages are x = 60, y = 40, z = 90. Only b (70 > 60) is strictly above its department average; c equals it, and y and z rows are not above.
More DBMS and SQL questions
- P(id, mgr) holds (1, NULL), (2, 1), (3, 1), (4, 1), (5, 2), (6, 2). How many rows does SELECT FROM P a JOIN P b ON a.mgr = b.mgr AND a.id…
- O(c, amt) holds (a, 100), (a, 250), (b, 300), (b, 50), (c, 400), (c, 20), (c, 30). What does SELECT SUM(CASE WHEN amt >= 100 THEN amt ELSE…
- R(A, B, C, D) has the functional dependencies A -> B and C -> D. R is decomposed into R1(A, B) and R2(C, D). Which statement is correct?
- Consider the schedule R1(A), W2(A), R3(A), W1(A) on a single item A. Is it conflict serializable?
- In a B+ tree, an internal node can hold up to p child pointers and p - 1 keys. The block size is 1024 bytes, a key takes 8 bytes and a…
- A(k) holds 1, 2, 3 and B(k, v) holds (1, NULL), (2, 5). How many rows does SELECT FROM A LEFT JOIN B ON A.k = B.k WHERE B.v IS NULL return?