ソースコード
with tmp_tbl_1 as (
select 
*
,'STEP' || row_number() over(partition by session_id order by ex_timestamp) as order_
from process_log 
)
,tmp_tbl_2 as (
select 
  *
  ,case when process_id = order_ then 'ok' else 'ng' end as check_
from tmp_tbl_1 
)
,tmp_tbl_3 as (
select * 
  ,sum(case when check_ = 'ng' then 1 when check_ = 'ok' then 0 else 1/0 end) over(partition by session_id order by ex_timestamp) as cum_ng
from tmp_tbl_2
)
select 
  process_id as PROCESS 
  ,count(case when cum_ng = 0 then session_id end) as CNT
from tmp_tbl_3
group by 1 
order by 1 
;
提出情報
提出日時2023/12/18 16:27:37
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者hattsuriboy
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量93 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
AC
93 MB
データパターン3
AC
86 MB
データパターン4
AC
91 MB