Question discussion

A table t(x) contains the values 1, NULL, 3, NULL, 5. What does the following query return?CREATE TABLE t(x INT); INSERT INTO t VALUES (1),…

917Medium DSSSB TGT Computer Science 0 replies 1 views
0

A table t(x) contains the values 1, NULL, 3, NULL, 5. What does the following query return?

CREATE TABLE t(x INT);
INSERT INTO t VALUES (1),(NULL),(3),(NULL),(5);
SELECT COUNT(*), COUNT(x), SUM(x) FROM t;
  • A5, 5, 9
  • B5, 3, 9
  • C3, 3, 9
  • D5, 3, 4
Correct answer: B

Explanation

COUNT(*) counts all 5 rows, COUNT(x) ignores NULLs (3) and SUM ignores NULLs (1 + 3 + 5 = 9).

Discussion 0

Nobody has replied yet. Start the discussion!