ソースコード
with wk as (
    select
        DATE(MONTHLY, '+1 month') AS MONTHLY
    from MRR_DATA
)
select
    COALESCE(wk.MONTHLY, m.MONTHLY) AS YM,
    COALESCE(SUM(NEW_MRR) OVER (ORDER BY wk.MONTHLY ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING), 0)
    + COALESCE(SUM(EXPANSION_MRR) OVER (ORDER BY wk.MONTHLY ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING), 0)
    - COALESCE(SUM(DOWNGRADE_MRR) OVER (ORDER BY wk.MONTHLY ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING), 0)
    - COALESCE(SUM(CHURN_MRR) OVER (ORDER BY wk.MONTHLY ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING), 0)
    AS MRR
from wk
full join MRR_DATA m
on wk.MONTHLY = m.MONTHLY
order by YM
提出情報
提出日時2023/02/28 01:28:47
コンテスト第5回 SQLコンテスト
問題MRRの集計
受験者fiction0111
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
AC
80 MB
データパターン3
AC
81 MB