Question discussion

What is the output of the following SQL statement?WITH RECURSIVE t(n) AS (SELECT 1 UNION ALL SELECT n * 2 FROM t WHERE n < 50) SELECT SUM(n…

1907Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following SQL statement?

WITH RECURSIVE t(n) AS (SELECT 1 UNION ALL SELECT n * 2 FROM t WHERE n < 50)
SELECT SUM(n) FROM t;
  • A63
  • B127
  • C126
  • D255
Correct answer: B

Explanation

The recursion produces 1, 2, 4, 8, 16, 32 and 64 (64 is generated from 32 because 32 < 50), whose sum is 127.

Discussion 0

Nobody has replied yet. Start the discussion!