oracle 兩個sql帶有order by的使用union/union all的時候報錯 'ORA-00933:sql命令未正確結束' 處理辦法


錯誤語句:select id,name from s1 order by stime union all select id,name from s2 order by stime 

報錯原因:oracle 搜索到order by后認為整個select語句就該結束了但是后面還有union all所以數據庫無法解析,導致報錯

處理辦法:with a1 as (select id,name from s1 order by stime) , a2 as (select id,name from s2 order by stime)  select * from a1 union all select * from a2


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM