CS FundamentalsHardGATE CS (PYQ pattern)

Table UP(a, b): (1,10), (2,20), (3,30). After UPDATE UP SET a = b, b = a; (standard SQL semantics), what is the sum of column a and the sum of column b?

  1. A. 60 and 6
  2. B. 60 and 60
  3. C. 6 and 6
  4. D. 54 and 12

Correct answer: A. 60 and 6

In standard SQL all right-hand sides see the OLD row values, so the assignments swap the columns: a becomes (10, 20, 30) and b becomes (1, 2, 3). An implementation that assigned sequentially would make both columns equal.

More DBMS and SQL questions

Exams that ask this topic