ソースコード
WITH months AS (
  SELECT DATE(generate_series(
    (SELECT MIN(MONTHLY)::date FROM MRR_DATA),
    (SELECT MAX(MONTHLY)::date + INTERVAL '1 month' FROM MRR_DATA),
    '1 month'::interval
  )) AS monthly
),
prev_mrr AS (
  SELECT 
    m.monthly,
    COALESCE(md.NEW_MRR, 0) AS new_mrr,
    COALESCE(md.EXPANSION_MRR, 0) AS expansion_mrr,
    COALESCE(md.DOWNGRADE_MRR, 0) AS downgrade_mrr,
    COALESCE(md.CHURN_MRR, 0) AS churn_mrr,
    COALESCE(LAG(
        COALESCE(md.NEW_MRR, 0) +
        COALESCE(md.EXPANSION_MRR, 0) -
        COALESCE(md.DOWNGRADE_MRR, 0) -
        COALESCE(md.CHURN_MRR, 0)
    ) OVER (ORDER BY m.monthly), 0) AS prev_mrr
  FROM months m
  LEFT JOIN MRR_DATA md
  ON m.monthly = md.MONTHLY::date
)
SELECT
  monthly AS YM,
  prev_mrr + new_mrr + expansion_mrr - downgrade_mrr - churn_mrr AS MRR
FROM prev_mrr
ORDER BY YM;
提出情報
提出日時2023/07/13 14:01:08
コンテスト第5回 SQLコンテスト
問題MRRの集計
受験者fish_man
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量81 MB
メッセージ
SQLITE_ERROR: unrecognized token: ":"
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
RE
81 MB
データパターン2
RE
78 MB
データパターン3
RE
80 MB