sql在sap hana中有时不起作用,错误代码为[23013]

时间:2019-02-19 06:25:00

标签: sql sap hana

有时我的SQL可以工作,有时却不能。

这是不起作用时的错误信息。

在254中无法执行“ W AS T AS(SELECT“ 0CALDAY”,-日历天“ YCOMPCODE”,-公司代码“ TXTSH”,-公司名称“ YCMSCODE”,-网点代码...“ ms 635 µs。 SAP DBTech JDBC:[2048]:列存储错误:搜索表错误:[23013]未知的视图属性; MBI_FR。#_ SYS_QO_COL_7ff043fdd220:c00000008f4f9e2.COL $ 9 $

这是SQL。

WITH T AS
(
SELECT
  "0CALDAY",                                                --日历天
  "YCOMPCODE",                                              --公司代码
  "TXTSH",                                                  --公司名称
  "YCMSCODE",                                               --网点代码
  "YCMSCN",                                                 --网点名称
  "LSLS_CURR",                                              --本期流水
  "LSLS_SYNC",                                              --同期流水
  "LSLS_SYNC_SYNC"                                          --前年流水
FROM  "MBI_FR"."SALES_FESTIVAL_ZP03" 
WHERE "0CALDAY" BETWEEN '2019-01-11' AND '2019-02-03'
    --经营形式参数设置
     ---公司参数设置
     AND "YESTYPE_ID" IN (SELECT "YESTYPE_ID" FROM "_SYS_BIC"."anta.mbi.role/CV_ROLE_YESTYPE"('PLACEHOLDER'= ('$$VAR_BRANDID$$','ANTA'),  'PLACEHOLDER'= ('$$VAR_USERID$$', '14040299')))--经营形式权限控制
    AND "YCOMPCODE" IN (SELECT "YCOMPCODE" FROM "_SYS_BIC"."anta.mbi.role/CV_ROLE_COMPCODE"('PLACEHOLDER' = ('$$VAR_USERID$$','14040299'))) --公司权限控制
    AND "YTNTYPE_ID"!='0'                            --排除特卖网点
    AND "LSLS_SYNC">=1            --取同期大于0的网点
 ),
 S AS 
       (
        SELECT
         "YCOMPCODE",                                          --公司代码
         MAX(LSLS) AS LSZG                                      --历史最高流水
        FROM
                (
                SELECT  
                 "0CALDAY",                                            --日历天
                 "YCOMPCODE",                                          --公司代码
                 "YCMSCODE",                                           --网点代码
                 "LSLS_SYNC" AS LSLS                                   --同期流水
                FROM T
                WHERE "0CALDAY"<='2019-02-03' AND "0CALDAY">='2019-01-11'
                UNION ALL
                SELECT 
                 "0CALDAY",                                           --日历天
                 "YCOMPCODE",                                         --公司代码
                 "YCMSCODE",                                          --网点代码
                 "LSLS_SYNC_SYNC"                                     --前年流水
                FROM T
                WHERE "0CALDAY"<='2019-02-03' AND "0CALDAY">='2019-01-11'
                UNION ALL
                SELECT  
                 "0CALDAY",                                           --日历天
                 "YCOMPCODE",                                         --公司代码
                 "YCMSCODE",                                          --网点代码
                 "LSLS_CURR"                                          --本期流水
                FROM T
                WHERE "0CALDAY"<='2019-02-01' AND "0CALDAY">='2019-01-11'
                )
        WHERE LSLS>=1
        GROUP BY 
         "YCOMPCODE"
        )
SELECT
    A.*
FROM
   (
    SELECT  
        "YCOMPCODE",                                     --公司代码
        "TXTSH",                                         --公司名称
        "YCMSCODE",                                      --网点代码
        "TXTSH"||'-'||"YCMSCN" AS "YCMSCN",              --公司名称与网点名称合并
        ROUND(ZRLS) AS "零售流水",                               --昨日流水
        1 AS JS,                                         --计数
        CASE WHEN LSZG=0 THEN 0 ELSE    ROUND(ZRLS/LSZG-1,3) END AS "流水增长",
        Row_Number() OVER(PARTITION BY "YCOMPCODE"  ORDER BY ZRLS DESC) RK   --根据公司按昨日流水倒序序号
        FROM
        (
            SELECT  
        T."YCOMPCODE",                                    --公司代码
        T."TXTSH",                                        --公司名称
        T."YCMSCODE",                                     --网点代码
        T."YCMSCN",                                       --网点名称
        MAX("LSLS_CURR") AS ZRLS,                         --昨日最高流水
        LSZG                                              --历史最高流水
        FROM T
        INNER JOIN S

        ON T.YCOMPCODE=S.YCOMPCODE
        WHERE LSLS_CURR>LSZG                                          --取昨日流水大于最高
            AND T."0CALDAY"='2019-02-02' 
        GROUP BY 
            T."YCOMPCODE",
            T."TXTSH",
            T."YCMSCODE",
            T."YCMSCN",
            LSZG
        )
)A
WHERE RK=1
ORDER BY "零售流水" DESC

0 个答案:

没有答案