The number of rows returned by SQL query on the given EMP table is ________…

2025

The number of rows returned by SQL query on the given EMP table is ________

SELECT *
FROM EMP
WHERE eno NOT IN (
SELECT manager FROM EMP);          

  1. A.

    0

  2. B.

    1

  3. C.

    3

  4. D.

    error

Attempted by 124 students.

Show answer & explanation

Correct answer: B

Step 1: The subquery SELECT manager FROM EMP returns the values 2, 3, 4, and NULL. Step 2: The main query SELECT * FROM EMP WHERE eno NOT IN (2, 3, 4, NULL) checks for eno values not in this list. Step 3: The eno values in the EMP table are 1, 2, 3, and 4. Step 4: eno = 1 is not in the list (2, 3, 4, NULL), so it is included. Step 5: eno = 2 is in the list, so it is excluded. Step 6: eno = 3 is in the list, so it is excluded. Step 7: eno = 4 is in the list, so it is excluded. Step 8: Only the row with eno = 1 is returned, so the count is 1.

Explore the full course: Capgemini Preparation