我正在尝试制作一份员工优先的报告。姓氏连同他们的经理名字和姓氏。我正在尝试自我加入。
我似乎无法成功编译。我还在学习,所以任何帮助/提示都会很棒。我正在使用Oracle SQL Developer。
SELECT EMPLOYEE.EMP_NUM "Employee ID",
EMPLOYEE.EMP_LNAME "Employee First Name",
EMPLOYEE.EMP_FNAME "Employee Last Name",
EMPLOYEE.EMP_MANAGER "Managers ID for Employee",
E2.EMP_LNAME as ManagerEMP_LNAME,
E2.EMP_FNAME as ManagerEMP_FNAME
FROM CARRM.EMPLOYEE
left outer join CARRM E2 on EMPLOYEE.EMP_MANAGER = E2.EMP_NUM;
答案 0 :(得分:2)
在from中,您提到了表“Carrm.Employee”的名称,但在左外连接中,看起来您只提到了数据库“Carrm”的名称。请尝试以下
SELECT E1.EMP_NUM "Employee ID",
E1.EMP_LNAME "Employee First Name",
E1.EMP_FNAME "Employee Last Name",
E1.EMP_MANAGER "Managers ID for Employee",
E2.EMP_LNAME as ManagerEMP_LNAME,
E2.EMP_FNAME as ManagerEMP_FNAME
FROM CARRM.EMPLOYEE E1
left outer join CARRM.Employee E2 on E1.EMP_MANAGER = E2.EMP_NUM;