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?

  1. A. 1050
  2. B. 1044
  3. C. 1047
  4. 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

Exams that ask this topic