gpt4 book ai didi

sqlplus - 错误: ORA-01789: query block has incorrect number of result columns

转载 作者:行者123 更新时间:2023-12-04 17:11:00 25 4
gpt4 key购买 nike

我有两种关系观点。

第一种观点:

CREATE VIEW VIEW1
AS
SELECT T#,
MAX(DECODE(LEG#,1,DEPARTURE)) ORIGIN,
MAX(DECODE(LEG#,1,DESTINATION)) DESTINATION1
FROM TRIPLEG
WHERE T# IN
(SELECT T# FROM TRIPLEG WHERE LEG# < 3
AND T# IN
(SELECT T# FROM TRIPLEG GROUP BY T#
HAVING COUNT(T#) < 3)
GROUP BY T#)
GROUP BY T#
ORDER BY T#;

第二种观点:
CREATE VIEW VIEW2
AS
SELECT T#,
MAX(DECODE(LEG#,2,DESTINATION)) DESTINATION1
FROM TRIPLEG
WHERE T# IN
(SELECT T# FROM TRIPLEG WHERE LEG# < 3
AND T# IN
(SELECT T# FROM TRIPLEG GROUP BY T#
HAVING COUNT(T#) < 3)
GROUP BY T#)
GROUP BY T#
ORDER BY T#;

我用
选择*从VIEW1
全联盟
选择*从VIEW2

而且我收到错误ORA-01789。

我想要实现的是
T#    |       ORIGIN   | DESTINATION1 | DESTINATION2
------------------------------------------------------
1 abc efg hij

我创建的是所谓的关系 View ?

最佳答案

两个 View 必须具有相同的列数才能执行UNION ALL。查看Oracle引用:The UNION ALL, INTERSECT, MINUS Operators

关于sqlplus - 错误: ORA-01789: query block has incorrect number of result columns,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13559955/

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