ソースコード
WITH tbl AS (
    SELECT
        A.MONTHLY
        , B.NEW_MRR
        , B.EXPANSION_MRR
        , B.DOWNGRADE_MRR
        , B.CHURN_MRR
        
    FROM (
        SELECT
        DATE(MAX(MONTHLY), '1 month') AS MONTHLY
        , null as NEW_MRR
        , null as EXPANSION_MRR
        , null as DOWNGRADE_MRR
        , null as CHURN_MRR
        FROM MRR_DATA
        
        UNION ALL
        SELECT * FROM MRR_DATA
        )AS A 
        LEFT OUTER JOIN MRR_DATA AS B
        ON A.MONTHLY = DATE(B.MONTHLY, '1 month')
        
    ORDER BY 1
    
), tbl2 AS (
    SELECT
        MONTHLY
        , IFNULL(NEW_MRR,0) + IFNULL(EXPANSION_MRR, 0)
            - IFNULL(DOWNGRADE_MRR, 0) - IFNULL(CHURN_MRR, 0) AS MRR
    FROM tbl
)

SELECT 
    tbl.MONTHLY AS YM
    , tbl2.MRR
        + IFNULL(tbl.NEW_MRR,0) + IFNULL(tbl.EXPANSION_MRR, 0)
        - IFNULL(tbl.DOWNGRADE_MRR, 0) - IFNULL(tbl.CHURN_MRR, 0) AS MRR
    
FROM tbl INNER JOIN tbl2 
    ON tbl.MONTHLY = DATE(tbl2.MONTHLY, '1 month')
ORDER BY 1

提出情報
提出日時2023/02/20 01:08:28
コンテスト第5回 SQLコンテスト
問題MRRの集計
受験者Udwei22
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
78 MB
データパターン2
WA
79 MB
データパターン3
WA
78 MB