The EMP table contains these columns: LAST NAME VARCHAR2(25) SALARY NUMBER(6,2) DEPARTMENT_ID NUMBER(6) You need to display the employees who have not been assigned to any department. You write the SELECT statement: SELECT LAST_NAME, SALARY, DEPARTMENT_ID FROM EMP WHERE DEPARTMENT_ID = NULL; What is true about this SQL statement?

  1. The SQL statement displays the desired results.

  2. The column in the WHERE clause should be changed to display the desired results.

  3. The operator in the WHERE clause should be changed to display the desired results.

  4. The WHERE clause should be changed to use an outer join to display the desired results.


Correct Option: C

AI Explanation

To answer this question, let's analyze the given SQL statement:

SELECT LAST_NAME, SALARY, DEPARTMENT_ID FROM EMP WHERE DEPARTMENT_ID = NULL;

The statement is attempting to display the employees who have not been assigned to any department. However, the statement is incorrect.

The correct comparison operator to check for a null value is not the equality operator (=), but rather the "IS NULL" operator. Therefore, option C is correct:

C. The operator in the WHERE clause should be changed to display the desired results.

The correct SQL statement should be:

SELECT LAST_NAME, SALARY, DEPARTMENT_ID FROM EMP WHERE DEPARTMENT_ID IS NULL;

Find more quizzes: