我有两种关系观点。
第一种观点:
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#;
我使用 SELECT * FROM VIEW1 UNION ALL SELECT * FROM VIEW2
我得到了错误 ORA-01789。
我想要实现的是
T# | ORIGIN | DESTINATION1 | DESTINATION2
------------------------------------------------------
1 abc efg hij
是我创建的考虑过的关系视图吗?