ソースコード
with tmp_tbl_1 as 
(
select 
  session_id 
  ,process_id 
  ,user_id 
  ,ex_timestamp
  ,row_number() over(partition by session_id, user_id order by ex_timestamp) as first_step 
from process_log 
)
-- select *
-- from tmp_tbl_1 
-- where first_step = 1 and process_id = 'STEP1'
,target_sessions as 
(
  select session_id 
  from tmp_tbl_1 
  where first_step = 1 and process_id = 'STEP1'
)
,tmp_tbl_2 as 
(
select * 
, lead(process_id, 1) over(partition by session_id order by ex_timestamp) as next_process
from process_log 
where session_id in (select session_id from target_sessions)
-- order by session_id, ex_timestamp
)
,tmp_tbl_3 as 
(
select *
, case when (next_process is null 
  or process_id = 'STEP1' and next_process = 'STEP2'
  or process_id = 'STEP2' and next_process = 'STEP3'
  or process_id = 'STEP3' and next_process = 'STEP4'
  or process_id = 'STEP4' and next_process = 'STEP5') then 'ok' 
  else 'bad' end as check_
from tmp_tbl_2 
-- order by session_id, ex_timestamp
)
,tmp_tbl_4 as 
(
select *
from tmp_tbl_3
where check_ = 'ok'
)
select 
  process_id as PROCESS 
  ,count(0) as CNT
from tmp_tbl_4
group by 1 
order by process
;
提出情報
提出日時2023/12/18 10:36:11
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者hattsuriboy
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量99 MB
メッセージ
テストケース(通過数/総数)
0/4
状態
メモリ使用量
データパターン1
WA
99 MB
データパターン2
WA
91 MB
データパターン3
WA
86 MB
データパターン4
WA
83 MB