查询失败oracle但在sql server中工作

c3frrgcw  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(284)

我有一个在sql server上运行得非常好的查询,但在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

我已经试过检查语法,但我没能解决一些文章。在消除别名的同时,尝试替换子查询中与父项不匹配的属性名,但没有任何效果。希望你能帮我,因为我已经到了我不知道下一步该怎么做的地步了!干杯

mctunoxg

mctunoxg1#

使用以下网站:https://rextester.com/l/oracle_online_compiler 我尝试了你的sql,得到了和你一样的错误。然后我开始把它简化为:
从blah中选择1作为rownum
但还是有同样的错误。我认为rownum是oracle中的一个保留字,不能将它用作字段别名。

相关问题