我有两张桌子——员工和经理。一位经理有许多员工。我想使用 CONNECT BY 和 GROUP BY 命令在父子关系中显示它。
EMPLOYEE 表的结构:
CREATE TABLE employee (
employee_id INTEGER,
manager_id INTEGER,
first_name VARCHAR2(10) NOT NULL,
last_name VARCHAR2(10) NOT NULL
);
经理表的结构:
CREATE TABLE manager(
manager_id INTEGER NOT NULL,
manager_dept VARCHAR2(20) NOT NULL,
first_name VARCHAR2(30) NOT NULL,
last_name VARCHAR2(30) NOT NULL
);
我写了这个查询:
SELECT E.EMPLOYEE_ID, M.MANAGER_ID, E.FIRST_NAME, E.LAST_NAME, CONNECT_BY_ISLEAF, CONNECT_BY_ISCYCLE
FROM EMPLOYEE E
LEFT OUTER JOIN MANAGER M
ON E.MANAGER_ID=M.MANAGER_ID
connect by NOCYCLE m.manager_id=prior e.employee_id
GROUP BY manager_id;
它给出了这个错误:
ORA-00918: column ambiguously defined
00918. 00000 - "column ambiguously defined"
Error at Line: 6 Column: 10
这个 group by 子句有什么问题?