ソースコード
with wk as (
    select
        MONTHLY,
        0 as MRR, 
        COALESCE(LAST_VALUE(NEW_MRR) OVER (ORDER BY MONTHLY ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING), 0) as LAST_NEW_MRR,
        COALESCE(LAST_VALUE(EXPANSION_MRR) OVER (ORDER BY MONTHLY ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING), 0) as LAST_EXPANSION_MRR,
        COALESCE(LAST_VALUE(DOWNGRADE_MRR) OVER (ORDER BY MONTHLY ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING), 0) as LAST_DOWNGRADE_MRR,
        COALESCE(LAST_VALUE(CHURN_MRR) OVER (ORDER BY MONTHLY ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING), 0) as LAST_CHURN_MRR
    from MRR_DATA
),
wk2 as (
    select
        MONTHLY,
        COALESCE(SUM(MRR) OVER (ORDER BY MONTHLY ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW), 0)
        + COALESCE(SUM(LAST_NEW_MRR) OVER (ORDER BY MONTHLY ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW), 0)
        + COALESCE(SUM(LAST_EXPANSION_MRR) OVER (ORDER BY MONTHLY ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW), 0)
        - COALESCE(SUM(LAST_DOWNGRADE_MRR) OVER (ORDER BY MONTHLY ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW), 0)
        - COALESCE(SUM(LAST_CHURN_MRR) OVER (ORDER BY MONTHLY ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW), 0)
        AS MRR
    from wk
    
)
select
    *
from wk2
提出情報
提出日時2023/02/28 01:21:06
コンテスト第5回 SQLコンテスト
問題MRRの集計
受験者fiction0111
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量80 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
80 MB
データパターン2
WA
80 MB
データパターン3
WA
80 MB