gpt4 book ai didi

sql - Oracle FETCH FIRST 1 ROW with UNION ALL 语句

转载 作者:行者123 更新时间:2023-12-05 09:10:43 26 4
gpt4 key购买 nike

我正在尝试使用 FETCH FIRST 1 ROW 在 SQL 中创建一个 UNION ALL 语句,但是当我这样做时它给我一个错误 MISSING KEYWORD

这是我的 SQL 的样子:

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 或任何类似性质的内容。

最佳答案

只需将每个部分放在括号中即可。无论如何,在 12.2 中工作:

( 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 )

对于任何感兴趣的人,我的实际测试查询是这样的:

(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);

关于sql - Oracle FETCH FIRST 1 ROW with UNION ALL 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61106222/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com