【ORACLE】使用 UNION 或者 UNION ALL 报错: ORA-00933:sql命令未正确结束
【ORACLE】使用 UNION 或者 UNION ALL 报错: ORA-00933:sql命令未正确结束
原因:两个order by导致的
union结果合并 + 排序,
union all只进行结果简单合并,不做排序,效率比union高 。
解决方法: 使用 with ... as ... select ...
例: with s1 as (select * from table1 t1 order by t1. tuid desc),
s2 as ( select * from table1 t2 order by t2. tuid desc )
select * from s1 union all select * from s2