Which SQL statement must you use?

Examine the commands used to create DEPARTMENT_DETAILS and COURSE_DETAILS:
SQL>CREATE TABLE DEPARTMENT_DETAILS
(DEPARTMENT_ID NUMBER PRIMARY KEY,
DEPARTMENT_NAME VARCHAR2(50),
HOD VARCHAR2(50));
SQL>CREATE TABLE COURSE_DETAILS
(COURSE_ID NUMBER PRIMARY KEY,
COURSE_NAME VARCHAR2(50),
DEPARTMENT_ID VARCHAR2(50));
You want to generate a list of all department IDs along with any course IDs that may have been assigned to
them.
Which SQL statement must you use?

Examine the commands used to create DEPARTMENT_DETAILS and COURSE_DETAILS:
SQL>CREATE TABLE DEPARTMENT_DETAILS
(DEPARTMENT_ID NUMBER PRIMARY KEY,
DEPARTMENT_NAME VARCHAR2(50),
HOD VARCHAR2(50));
SQL>CREATE TABLE COURSE_DETAILS
(COURSE_ID NUMBER PRIMARY KEY,
COURSE_NAME VARCHAR2(50),
DEPARTMENT_ID VARCHAR2(50));
You want to generate a list of all department IDs along with any course IDs that may have been assigned to
them.
Which SQL statement must you use?

A.
SELECT d.department_id, c.course_id FROM department_details d RIGHT OUTER JOIN
course_details c ON (d.department_id=c. department_id);

B.
SELECT d.department_id, c.course_id FROM department_details d LEFT OUTER JOIN
course_details c ON (d.department_id=c. department_id);

C.
SELECT d.department_id, c.course_id FROM course_details c LEFT OUTER JOIN
department_details d ON (c.department_id=d. department_id);

D.
SELECT d.department_id, c.course_id FROM department_details d RIGHT OUTER JOIN
course_details c ON (c.department_id=d. department_id);



Leave a Reply 0

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