Which statement is true regarding the output of the following SQLSQL statement?

View the Exhibit and examine the description of the EMPLOYEES and DEPARTMENTS tables. You want to display the LAST_NAME for the employees, LAST_NAME for the manager of the employees, and the DEPARTMENT_NAME for the employees having 100 as MANAGER_ID.
The following SQL statement was written:
SELECT m.last_name "Manager", e.last_name "Employee", department_name "Department" FROM employees m JOIN employees e
ON (m.employee_id = e.manager_id)
WHERE e.manager_id=100
JOIN departments d
ON (e.department_id = d.department_id);
Which statement is true regarding the output of this SQL statement?

View the Exhibit and examine the description of the EMPLOYEES and DEPARTMENTS tables

You want to display the LAST_NAME for the employees, LAST_NAME for the manager of the employees, and the DEPARTMENT_NAME for the employees having 100 as MANAGER_ID.

The following SQL statement was written:
SELECT m.last_name “Manager”, e.last_name “Employee”, department_name “Department” FROM employees m JOIN employees e
ON (m.employee_id = e.manager_id)
WHERE e.manager_id=100
JOIN departments d
ON (e.department_id = d.department_id);

Which statement is true regarding the output of this SQL statement?

A.
The statement would provide the desired results.

B.
The statement would not execute because the ON clause is written twice.

C.
The statement would not execute because the WHERE clause is wrongly placed.

D.
The statement would not execute because the self join uses the ON clause instead of the USING clause.



Leave a Reply 3

Your email address will not be published. Required fields are marked *


Cindy

Cindy

Does it mean that “WHERE” must be placed after the JOIN ON?

laura

laura

you can add the condition to on cluase:
select m.last_name “Manager”, e.last_name “Employee” ,department_name “Department” from employees m join employees e
on (m.employee_id=e.manager_id)and e.manager_id=100
join departments d on (e.department_id=d.department_id);

laura

laura

or put the where at the end of the last join:
select m.last_name “Manager”, e.last_name “Employee” ,department_name “Department” from
employees m join employees e on (m.employee_id=e.manager_id)
join departments d on (e.department_id=d.department_id)
where e.manager_id=100 ;