Question discussion

What does the following query return?CREATE TABLE a(x INT); INSERT INTO a VALUES (1),(2),(3); CREATE TABLE b(y INT); INSERT INTO b VALUES (…

1378Medium DSSSB TGT Computer Science 0 replies 2 views
0

What does the following query return?

CREATE TABLE a(x INT);
INSERT INTO a VALUES (1),(2),(3);
CREATE TABLE b(y INT);
INSERT INTO b VALUES (2),(NULL);
SELECT COUNT(*) FROM a WHERE x NOT IN (SELECT y FROM b);
  • A0
  • B1
  • C2
  • D3
Correct answer: A

Explanation

Because b contains a NULL, x NOT IN (2, NULL) is FALSE for x = 2 and UNKNOWN for x = 1 and 3, so no row qualifies and the count is 0.

Discussion 0

Nobody has replied yet. Start the discussion!