-1

我在 EM 做报告,我需要在这里弄清楚

我有这个查询:

SELECT
*
FROM
(
    SELECT DISTINCT
    patch.host as "PHost",
    patch.home_location as "PDirectory",
    patch.home_name as "PHome",
    MAX(patch.INSTALLATION_TIME) as "Patched (Date)",
    MAX(patch.PATCH_RELEASE) as "PVersion",
    listagg(patch,',') WITHIN GROUP (ORDER BY patch) "Patches"
    FROM
    mgmt$applied_patches patch
    GROUP BY patch.host, patch.home_location,patch.home_name
    ORDER BY patch.host, patch.home_location
) "PCH",
(
    SELECT DISTINCT 
    T1.PROPERTY_VALUE as "MHost",
    T2.PROPERTY_VALUE as "MDirectory",
    T3.PROPERTY_VALUE as "MVersion",
    count(T4.PROPERTY_VALUE) as "Count of SID",
    listagg(T4.PROPERTY_VALUE,',') WITHIN GROUP (ORDER BY T4.PROPERTY_VALUE) as "SID"
    FROM
    MGMT$TARGET_PROPERTIES T1,
    MGMT$TARGET_PROPERTIES T2,
    MGMT$TARGET_PROPERTIES T3,
    MGMT$TARGET_PROPERTIES T4
    WHERE
    T1.TARGET_GUID = T2.TARGET_GUID
    and T1.TARGET_GUID = T3.TARGET_GUID
    and T1.TARGET_GUID = T4.TARGET_GUID
    and T1.PROPERTY_NAME = 'MachineName'
    and T2.PROPERTY_NAME = 'OracleHome'
    and T3.PROPERTY_NAME = 'Version'
    and T4.PROPERTY_NAME = 'SID'
    GROUP BY T1.PROPERTY_VALUE, T2.PROPERTY_VALUE, T3.PROPERTY_VALUE
) "MGM"
WHERE
PDirectory = MDirectory

我收到错误 ORA-00904: "MDIRECTORY":....

我尝试了很多组合!(PCH.PDirectory = MGM.MDirectory, ......) 没有任何效果

干杯

4

2 回答 2

2

Oracle 中的混合大小写名称令人讨厌,而您刚刚被它们咬了。

采用:

"PDirectory" = "MDirectory"

.. 或者最好不要使用需要引用的特殊名称。

于 2012-05-31T10:43:09.153 回答
1

好...

这不起作用:

SELECT * FROM
(SELECT DUMMY AS  "PDirectory" FROM DUAL) "PCH",
(SELECT DUMMY AS  "MDirectory" FROM DUAL) "MGR"
WHERE PDIRECTORY = MDIRECTORY

但这有效:

SELECT * FROM
(SELECT DUMMY AS  "PDirectory" FROM DUAL) "PCH",
(SELECT DUMMY AS  "MDirectory" FROM DUAL) "MGR"
where "PCH"."PDirectory" = "MGR"."MDirectory"

相应地更改您的查询。

于 2012-05-31T10:43:13.777 回答