ソースコード
WITH TMP AS(
SELECT 
    MONTHLY
    ,NEW_MRR
    ,EXPANSION_MRR
    ,DOWNGRADE_MRR
    ,CHURN_MRR
    ,LAG(NEW_MRR,1) 
        OVER(ORDER BY MONTHLY ASC) AS FR_NM
    ,LAG(EXPANSION_MRR,1) 
        OVER(ORDER BY MONTHLY ASC) AS FR_EM
    ,LAG(DOWNGRADE_MRR,1) 
        OVER(ORDER BY MONTHLY ASC) AS FR_DM
    ,LAG(CHURN_MRR,1) 
        OVER(ORDER BY MONTHLY ASC) AS FR_CM
FROM
    MRR_DATA
)
,TMP2 AS(
SELECT
    MONTHLY
    ,FR_NM+ FR_EM - FR_DM - FR_CM AS MRR
FROM
    TMP
)

SELECT
    MONTHLY
    ,CASE WHEN (SUM(MRR) OVER(ORDER BY MONTHLY ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) IS NOT NULL THEN (SUM(MRR) OVER(ORDER BY MONTHLY ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) ELSE 0 END  AS MRR
FROM
    TMP2
提出情報
提出日時2023/08/10 15:43:39
コンテスト第5回 SQLコンテスト
問題MRRの集計
受験者ebizo777
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
79 MB
データパターン2
WA
81 MB
データパターン3
WA
81 MB