ソースコード
with zzz as (
select
  *
from MRR_DATA
 union all
 select
   date(MONTHLY, '+1 months', 'start of month')
  ,0,0,0,0
from MRR_DATA
group by MONTHLY
having MONTHLY = MAX(MONTHLY)
)
, aaa as (
select
  *
 ,LAG (NEW_MRR, 1, 0) OVER (ORDER BY MONTHLY) AS LAG_NEW_MRR
 ,LAG (EXPANSION_MRR, 1, 0) OVER (ORDER BY MONTHLY) AS LAG_EXPANSION_MRR
 ,LAG (DOWNGRADE_MRR, 1, 0) OVER (ORDER BY MONTHLY) AS LAG_DOWNGRADE_MRR
 ,LAG (CHURN_MRR, 1, 0) OVER (ORDER BY MONTHLY) AS LAG_CHURN_MRR
from zzz
)
, bbb as (
  select
  *, LAG_NEW_MRR+LAG_EXPANSION_MRR-LAG_DOWNGRADE_MRR-LAG_CHURN_MRR as aaa
  from
  aaa
)
select
MONTHLY as YM,
  SUM(aaa) OVER (
    ORDER BY
      MONTHLY ASC
      ROWS BETWEEN UNBOUNDED  PRECEDING AND CURRENT ROW
  ) AS MRR
from bbb
order by MONTHLY
提出情報
提出日時2023/02/19 16:19:31
コンテスト第5回 SQLコンテスト
問題MRRの集計
受験者kon-kitsune
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量92 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
92 MB
データパターン2
WA
85 MB
データパターン3
WA
90 MB