ソースコード
with diff as (
    select monthly, coalesce(new_mrr, 0) + coalesce(expansion_mrr, 0) - coalesce(downgrade_mrr, 0) - coalesce(churn_mrr, 0) as value
    from mrr_data
    union all
    select date(max(monthly), '+1 month'), null
    from mrr_data
)
select diff.monthly as YM, coalesce(sum(diff2.value), 0) as MRR
from diff
left join diff as diff2
on diff.monthly > diff2.monthly
group by diff.monthly
order by diff.monthly asc
提出情報
提出日時2023/02/20 11:39:42
コンテスト第5回 SQLコンテスト
問題MRRの集計
受験者kkkkk
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量82 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
79 MB
データパターン2
AC
78 MB
データパターン3
AC
82 MB