SQL> SELECT empno AS 编码, ename AS 名称, nvl(mgr, deptno) AS 上级编码 FROM emp
2 order by empno
3 UNION ALL
4 SELECT deptno AS 编码, dname AS 名称, NULL AS 上级编码 FROM dept
5 order by deptno;
UNION ALL
*
第 3 行出现错误:
ORA-00933: SQL 命令未正确结束
SQL> SELECT empno AS 编码, ename AS 名称, nvl(mgr, deptno) AS 上级编码 FROM emp
2 /*order by empno*/
3 UNION ALL
4 SELECT deptno AS 编码, dname AS 名称, NULL AS 上级编码 FROM dept
5 order by 1;
编码 名称 上级编码
---------- -------------- ----------
10 ACCOUNTING
20 RESEARCH
30 SALES
40 OPERATIONS
7369 SMITH 7902
7499 ALLEN 7698
7521 WARD 7698
7566 JONES 7839
7654 MARTIN 7698
union all合并记录
最新推荐文章于 2021-01-30 05:43:05 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)