CS FundamentalsHardWipro Elite · LTIMindtree
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 0 END) - COUNT(CASE WHEN amt < 100 THEN 1 END) FROM O return?
- A. 1050
- B. 1044
- C. 1047
- D. 1150
Correct answer: C. 1047
The CASE sum is 100 + 250 + 300 + 400 = 1050. COUNT ignores the NULLs from the missing ELSE, so it counts only the 3 rows with amt < 100: 1050 - 3 = 1047.
More DBMS and SQL questions
- 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?
- E(n, sal) holds (a, 10), (b, 20), (c, 30), (d, 40). After UPDATE E SET sal = sal + 10 WHERE sal < (SELECT AVG(sal) FROM E), what is…
- An ER diagram has entities Student, Course and Prof. Student and Course are related by Enrols (many-to-many, with attribute grade). Each…