nerdexam
Oracle

1Z0-061 · Question #42

Examine the structure of the employees table: There is a parent/child relationship between EMPLOYEE_ID and MANAGER_ID. You want to display the name, joining date, and manager for all the employees…

The correct answer is B. Option B. Try it yourself with the scott.emp table: SELECT e.ename,NVL(m.ename,'No Manager') Manager FROM emp e JOIN emp m ON (e.mgr=m.empno); SELECT e.ename,NVL(m.ename,'No Manager') Manager FROM emp e LEFT OUTER JOIN emp m ON (e.mgr=m.empno); SELECT e.ename,NVL(m.ename,'No Manager')…

Displaying Data from Multiple Tables using Joins

Question

Examine the structure of the employees table:

There is a parent/child relationship between EMPLOYEE_ID and MANAGER_ID. You want to display the name, joining date, and manager for all the employees. Newly hired employees are yet to be assigned a department or a manager. For them, 'No Manager1 should be displayed in the manager column. Which SQL query gets the required output?

Exhibits

1Z0-061 question #42 exhibit 1
1Z0-061 question #42 exhibit 2

Options

  • AOption A
  • BOption B
  • COption C
  • DOption D

How the community answered

(19 responses)
  • A
    5% (1)
  • B
    74% (14)
  • C
    5% (1)
  • D
    16% (3)

Explanation

Try it yourself with the scott.emp table: SELECT e.ename,NVL(m.ename,'No Manager') Manager FROM emp e JOIN emp m ON (e.mgr=m.empno); SELECT e.ename,NVL(m.ename,'No Manager') Manager FROM emp e LEFT OUTER JOIN emp m ON (e.mgr=m.empno); SELECT e.ename,NVL(m.ename,'No Manager') Manager FROM emp e NATURAL JOIN emp m ON (e.mgr=m.empno); Not A: It works too, but it is a INNER JOIN and won't print the rows with 'No Manager'. Not C: It works too, but the join order is wrong, and therefor the rows with 'No Manager' not Not D: Syntax error. There is no ON ... in Natural JOIN

Topics

#outer join#self join#NULL handling#employee hierarchy

Community Discussion

No community discussion yet for this question.

Full 1Z0-061 Practice