ソースコード

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
  ) AS MRR
from bbb
order by MONTHLY
提出情報
提出日時2023/02/19 16:10:17
コンテスト第5回 SQLコンテスト
問題MRRの集計
受験者kon-kitsune
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量89 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
89 MB
データパターン2
WA
89 MB
データパターン3
WA
83 MB