返回顶部

收藏

union带有order by的sql时,order by需要放到子查询语法才有效

更多
--union和order by连用需要放在子查询中,否则会报错
--例如:
--错误写法:
select * from dept1 order by deptno
union
select * from dept2 order by deptno;
--ORA-00933 "SQL command not properly ended"
--正确写法:
select * from (select * from dept1 order by deptno)
union
select * from (select * from dept2 order by deptno);

标签:sql

收藏

0人收藏

支持

0

反对

0