Management & CommerceVery hardBusiness analyst · SQL test

Table s(id, amt, status) has (1, 100, paid), (2, 250, due), (3, 500, paid), (4, 1000, refund), (5, 250, paid). What does SELECT 1.0 * SUM(CASE WHEN status = 'paid' THEN amt ELSE 0 END) / SUM(amt) FROM s return?

  1. A. 0.6
  2. B. About 0.85
  3. C. 0
  4. D. About 0.405

Correct answer: D. About 0.405

Paid amounts: 100 + 500 + 250 = 850; total = 2,100; share ≈ 0.405. 0.6 is the share of paid rows (3 of 5), not of value. Multiplying by 1.0 avoids integer division, which in some databases would give 0.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic