ソースコード
with history AS
(
select
     session_id 
    ,process_id 
    ,lead(process_id, 1) OVER (partition by session_id order by ex_timestamp) P2
    ,lead(process_id, 2) OVER (partition by session_id order by ex_timestamp) P3
    ,lead(process_id, 3) OVER (partition by session_id order by ex_timestamp) P4
    ,lead(process_id, 4) OVER (partition by session_id order by ex_timestamp) P5
from
    process_log
group by 
    session_id, process_id
), result as (
select process_id PROCESS, count(*) CNT FROM history where process_id = 'STEP1'
UNION ALL
select P2 PROCESS, count(*) CNT FROM history where process_id = 'STEP1' AND P2 = 'STEP2'
UNION ALL
select P3 PROCESS, count(*) CNT FROM history where process_id = 'STEP1' AND P2 = 'STEP2' AND P3 = 'STEP3'
UNION ALL
select P4 PROCESS, count(*) CNT FROM history where process_id = 'STEP1' AND P2 = 'STEP2' AND P3 = 'STEP3' AND P4 = 'STEP4'
UNION ALL
select P5 PROCESS, count(*) CNT FROM history where process_id = 'STEP1' AND P2 = 'STEP2' AND P3 = 'STEP3' AND P4 = 'STEP4' AND P5 = 'STEP5'
) 
select PROCESS, CNT FROM result order by 1
;
提出情報
提出日時2023/12/15 16:05:49
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者Kojiron
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量96 MB
メッセージ
テストケース(通過数/総数)
2/4
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
84 MB
データパターン3
WA
87 MB
データパターン4
WA
96 MB