0

我有一个在 SQL 服务器上完美运行的查询,但在 Oracle 中,我收到以下错误:

ORA-00923: 在预期的地方找不到 FROM 关键字

SELECT  
MyApps.AppConfigurationId, 
MyApps.GUID, 
MyApps.AppName, 
MyApps.BinaryData, 
MyApps.Color1, 
MyApps.UserCreatorName, 
MyApps.CreatedAt,  
MyApps.UserUpdaterName, 
MyApps.UpdatedAt, 
MyApps.UserPublisherName, 
MyApps.LastPublishedAt, 
MyApps.AppConfigStateId, 
MyApps.AppConfigStateLabel 
FROM 
(  
    SELECT 
        ROW_NUMBER() OVER ( 
            PARTITION BY  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."ID" 
            ORDER BY LastestPublishInfo."PUBLISHEDAT" DESC 
        ) AS RowNum, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."ID" AS AppConfigurationId, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."GUID", 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."NAME" AS AppName, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPICON1"."BINARYDATA", 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_COLORPA1"."COLOR1", 
        UserCreator."NAME" AS UserCreatorName, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."CREATEDAT",  
        UserUpdater."NAME" AS UserUpdaterName, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."UPDATEDAT", 
        LastestPublishInfo.PublisherName AS UserPublisherName , 
        LastestPublishInfo."PUBLISHEDAT" AS LastPublishedAt, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."APPCONFIGSTATEID", 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON20"."LABEL" AS AppConfigStateLabel            

    FROM     "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266" JOIN  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON20" 
                ON ( "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."APPCONFIGSTATEID" =  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON20"."ID" AND 
                     "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."PARENTAPPCONFIGID" IS NULL AND 
                     "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."ISACTIVE" = 1 
                   ) 
            JOIN  "OSADMIN_OSDEV1"."OSSYS_USER_T266" UserCreator 
                ON ( "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."CREATEDBY" = UserCreator."ID") 
            LEFT JOIN  "OSADMIN_OSDEV1"."OSSYS_USER_T266" UserUpdater 
                ON ( "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."UPDATEDBY" = UserCreator."ID") 
            LEFT JOIN  "OSADMIN_OSDEV1"."OSUSR_4BQ_COLORPA1" 
                ON( "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."COLORPALETTEID" =  "OSADMIN_OSDEV1"."OSUSR_4BQ_COLORPA1"."ID") 
            LEFT JOIN               
                ( 
                    SELECT   "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16"."APPCONFIGURATIONID", 
                             "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16"."PUBLISHEDAT", 
                            UserPublisher."NAME" AS PublisherName 
                    FROM     "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16" LEFT JOIN  "OSADMIN_OSDEV1"."OSSYS_USER_T266" UserPublisher 
                                ON ( "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16"."PUBLISHEDBY" = UserPublisher."ID") 
                    WHERE    "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16"."PUBLISHEDAT" IS NOT NULL  
                            AND 
                             "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16"."ISACTIVE" = 0 
                             
                ) LastestPublishInfo 
                ON (LastestPublishInfo.AppConfigurationId =  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."ID") 
            LEFT JOIN  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPICON1" 
                ON(  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPICON1"."APPCONFIGURATIONID" =  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."ID" ) 
) MyApps 
WHERE MyApps.RowNum = 1 
ORDER BY  
MyApps.UpdatedAt DESC 

我已经尝试按照一些文章检查语法,但我无法解决它。在别名周围添加了“,尝试替换子查询中的属性名称不匹配父项,但没有任何效果。希望你能帮我解决这个问题,因为我已经到了我不知道接下来要尝试什么的地步!干杯

4

1 回答 1

1

使用以下网站:https ://rextester.com/l/oracle_online_compiler 我尝试了您的 SQL 并得到了与您相同的错误。然后我开始将其简化为:

从 blah 中选择 1 作为 RowNum

并且仍然得到同样的错误。我认为 RowNum 是 Oracle 中的保留字,不能用作字段别名。

于 2020-07-19T23:37:31.247 回答