Question discussion

What is the output of the following SQL statements?CREATE TABLE t(v INT); INSERT INTO t VALUES (3),(8),(5),(10); UPDATE t SET v = CASE WHEN…

2168Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following SQL statements?

CREATE TABLE t(v INT);
INSERT INTO t VALUES (3),(8),(5),(10);
UPDATE t SET v = CASE WHEN v > 5 THEN v - 5 ELSE v + 5 END;
SELECT SUM(v) FROM t;
  • A18
  • B21
  • C31
  • D26
Correct answer: D

Explanation

The values become 8, 3, 10 and 5 (5 is not greater than 5, so it gets +5); their sum is 26.

Discussion 0

Nobody has replied yet. Start the discussion!