ソースコード
select t1.MONTHLY as YM
    ,t3.conMRR + t2.NEW_MRR + t2.EXPANSION_MRR - t2.DOWNGRADE_MRR - t2.CHURN_MRR as MRR
from MRR_DATA t1
    join (
        select MONTHLY, NEW_MRR, EXPANSION_MRR, DOWNGRADE_MRR, CHURN_MRR
            ,(NEW_MRR + EXPANSION_MRR - DOWNGRADE_MRR - CHURN_MRR) as conMRR
        from MRR_DATA
        union all
        select 
            date(min(MONTHLY), '-1 months') as MONTHLY
            ,0 as NEW_MRR
            ,0 as EXPANSION_MRR
            ,0 as DOWNGRADE_MRR
            ,0 as CHURN_MRR
            ,0 as conMRR
        from MRR_DATA
        union all
        select 
            date(min(MONTHLY), '-2 months') as MONTHLY
            ,0 as NEW_MRR
            ,0 as EXPANSION_MRR
            ,0 as DOWNGRADE_MRR
            ,0 as CHURN_MRR
            ,0 as conMRR
        from MRR_DATA
    ) t2
        on t1.MONTHLY = date(t2.MONTHLY, '+1 months')
    join (
        select MONTHLY, NEW_MRR, EXPANSION_MRR, DOWNGRADE_MRR, CHURN_MRR
            ,(NEW_MRR + EXPANSION_MRR - DOWNGRADE_MRR - CHURN_MRR) as conMRR
        from MRR_DATA
        union all
        select 
            date(min(MONTHLY), '-1 months') as MONTHLY
            ,0 as NEW_MRR
            ,0 as EXPANSION_MRR
            ,0 as DOWNGRADE_MRR
            ,0 as CHURN_MRR
            ,0 as conMRR
        from MRR_DATA
        union all
        select 
            date(min(MONTHLY), '-2 months') as MONTHLY
            ,0 as NEW_MRR
            ,0 as EXPANSION_MRR
            ,0 as DOWNGRADE_MRR
            ,0 as CHURN_MRR
            ,0 as conMRR
        from MRR_DATA
    ) t3
        on t1.MONTHLY = date(t3.MONTHLY, '+2 months')
order by t1.MONTHLY
提出情報
提出日時2023/02/19 19:07:46
コンテスト第5回 SQLコンテスト
問題MRRの集計
受験者S_Katou
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
86 MB
データパターン2
WA
83 MB
データパターン3
WA
78 MB