本文介紹了Oracle FETCH FIRST 1 ROW with UNION ALL 語句的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我正在嘗試使用 FETCH FIRST 1 ROW 在 SQL 中創建一個 UNION ALL 語句,但是當我這樣做時,它給了我一個錯誤 MISSING KEYWORD
I'm trying to create a UNION ALL statement in SQL using the FETCH FIRST 1 ROW however when I do that it gives me an error MISSING KEYWORD
這是我的 SQL 的樣子:
Here's what my SQL looks like:
Select * From tabl1 where Date = '04-MAR-2020' FETCH FIRST 1 ROW
UNION ALL
Select * From tabl1 where Date = '05-MAR-2020' FETCH FIRST 1 ROW
是這樣可行的.我希望將其保留為單個語句,而不是添加 SUBQUERY 或任何此類性質的內容.
is something like this doable. I would like to keep this as a single statement rather than adding a SUBQUERY or anything of that nature.
推薦答案
只需將每個部分放在括號中即可.無論如何都可以在 12.2 中使用:
Just put the each part in parentheses. Works in 12.2, anyway:
( Select * From tabl1 where Date = '04-MAR-2020' FETCH FIRST 1 ROW )
UNION ALL
( Select * From tabl1 where Date = '05-MAR-2020' FETCH FIRST 1 ROW )
我的實際測試查詢,對于任何感興趣的人是這樣的:
My actual test query, for anyone interested was this:
(select object_name
from user_objects
where object_type = 'TABLE'
order by object_name
fetch first 1 row only)
UNION ALL
(select object_name
from user_objects
where object_type = 'VIEW'
order by object_name
fetch first 1 row only);
這篇關于Oracle FETCH FIRST 1 ROW with UNION ALL 語句的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!