ソースコード
SELECT
    MONTHLY,
    (LAG_MRR
     + LAG_NEW_MRR
     + LAG_EXPANSION_MRR
     - LAG_DOWNGRADE_MRR
     - LAG_CHURN_MRR) AS MRR
FROM (
    SELECT
        MONTHLY,
        (COALESCE(LAG(NEW_MRR, 2) OVER (ORDER BY MONTHLY), 0)
         + COALESCE(LAG(EXPANSION_MRR, 2) OVER (ORDER BY MONTHLY), 0)
         + COALESCE(LAG(DOWNGRADE_MRR, 2) OVER (ORDER BY MONTHLY), 0)
         + COALESCE(LAG(CHURN_MRR, 2) OVER (ORDER BY MONTHLY), 0)
        ) AS LAG_MRR,
        COALESCE(LAG(NEW_MRR, 1) OVER (ORDER BY MONTHLY), 0) AS LAG_NEW_MRR,
        COALESCE(LAG(EXPANSION_MRR, 1) OVER (ORDER BY MONTHLY), 0) AS LAG_EXPANSION_MRR,
        COALESCE(LAG(DOWNGRADE_MRR, 1) OVER (ORDER BY MONTHLY), 0) AS LAG_DOWNGRADE_MRR,
        COALESCE(LAG(CHURN_MRR, 1) OVER (ORDER BY MONTHLY), 0) AS LAG_CHURN_MRR
    FROM
        MRR_DATA
)
ORDER BY
    MONTHLY
;
提出情報
提出日時2023/04/14 18:19:53
コンテスト第5回 SQLコンテスト
問題MRRの集計
受験者naku6aru
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
84 MB
データパターン2
WA
79 MB
データパターン3
WA
84 MB