Question discussion

What is the output of the following SQL statements?CREATE TABLE m(n TEXT, s INT); INSERT INTO m VALUES ('a',85),('b',55),('c',70),('d',40);…

1957Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following SQL statements?

CREATE TABLE m(n TEXT, s INT);
INSERT INTO m VALUES ('a',85),('b',55),('c',70),('d',40);
SELECT SUM(CASE WHEN s >= 60 THEN 1 ELSE 0 END) FROM m;
  • A2
  • B1
  • C3
  • D4
Correct answer: A

Explanation

The CASE expression gives 1 for the scores 85 and 70 and 0 for the others, so the sum is 2.

Discussion 0

Nobody has replied yet. Start the discussion!