在ORACLE中,我试图创建一个视图,它是一个视图的并集:
CREATE VIEW "TEST_ALL"
AS
( SELECT SYS_EXTRACT_UTC(SYSTIMESTAMP) as DT, M_ID, COUNT(DISTINCT OBJECT_ID) as RESULT
FROM VIEW1
UNION ALL
SELECT SYS_EXTRACT_UTC(SYSTIMESTAMP) as DT, M_ID, COUNT(DISTINCT OBJECT_ID) as RESULT
FROM VIEW
UNION ALL
SELECT SYS_EXTRACT_UTC(SYSTIMESTAMP) as DT, M_ID, COUNT(DISTINCT OBJECT_ID) as RESULT
FROM VIEW3
UNION ALL
SELECT SYS_EXTRACT_UTC(SYSTIMESTAMP) as DT, M_ID, COUNT(DISTINCT OBJECT_ID) as RESULT
FROM VIEW4
UNION ALL
SELECT SYS_EXTRACT_UTC(SYSTIMESTAMP) as DT, M_ID, COUNT(DISTINCT OBJECT_ID) as RESULT
FROM VIEW5
UNION ALL
SELECT SYS_EXTRACT_UTC(SYSTIMESTAMP) as DT, M_ID, COUNT(DISTINCT OBJECT_ID) as RESULT
FROM VIEW6
)
这不管用吗但是,当我删除M_ID
时,它创建了视图。
当我只是联合所有的内部意见,它的工作。有人能帮帮我吗?
1条答案
按热度按时间js81xvg61#
在查询中:
然后:
SYS_EXTRACT_UTC(SYSTIMESTAMP)
对于所有行有效地是恒定的;COUNT(DISTINCT OBJECT_ID)
是聚合;和/或M_ID
是一个非聚合列。您混合了聚合列和非聚合列,并且没有
GROUP BY
子句。将每个子查询更改为:
1.
1.或者使用解析函数来生成计数:
并对每个视图重复此操作。