ソースコード
select
YM as YM
,sum(mrr) over(order by YM) as MRR
from(
    select
    monthly as YM
    --,strftime(DATE(monthly,'localtime','+1 MONTH')) as prev2
    ,ifnull(prev_new_mrr+prev_expansion_mrr-prev_downgrade_mrr-prev_churn_mrr,0) as MRR
    from (select monthly from mrr_data union select strftime(DATE(monthly,'localtime','+1 MONTH')) from mrr_data)as m1
    left outer join(
        select
        strftime(DATE(monthly,'localtime','+1 MONTH')) as prev
        ,new_mrr as prev_new_mrr
        ,expansion_mrr as prev_expansion_mrr
        ,downgrade_mrr as prev_downgrade_mrr
        ,churn_mrr as prev_churn_mrr
        from mrr_data
    ) as m2
    on m1.monthly = m2.prev
)as m0
order by YM
提出情報
提出日時2024/05/20 09:04:40
コンテスト第5回 SQLコンテスト
問題MRRの集計
受験者HamamatsuUnagi
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
84 MB
データパターン3
AC
85 MB