Table Stock(item, qty) has rows (‘a’,8), (‘b’,12), (‘c’,20), (‘d’,15). UPDATE Stock SET qty = qty – 5 WHERE qty > 10; SELECT SUM(qty) FROM Stock; What is the result?
Correct answer D. 40
Explanation
The UPDATE changes only rows whose qty exceeds 10: b, c and d each fall by 5 to 7, 15 and 10. Row a (8) is untouched. The new total is 8 + 7 + 15 + 10 = 40. The answer 35 assumes every row was reduced, which is what happens if the WHERE clause is left out; the original total before the update was 55.
Answer checked How we write and check questions
Discussion