ソースコード
        with history AS
        (
        select
             session_id 
            ,lag(process_id) OVER (partition by session_id order by ex_timestamp) bef
            ,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 bef is null AND  process_id = 'STEP1'
        UNION ALL
        select P2 PROCESS, count(*) CNT FROM history where bef is null AND process_id = 'STEP1' AND P2 = 'STEP2'
        UNION ALL
        select P3 PROCESS, count(*) CNT FROM history where bef is null AND process_id = 'STEP1' AND P2 = 'STEP2' AND P3 = 'STEP3'
        UNION ALL
        select P4 PROCESS, count(*) CNT FROM history where bef is null AND process_id = 'STEP1' AND P2 = 'STEP2' AND P3 = 'STEP3' AND P4 = 'STEP4'
        UNION ALL
        select P5 PROCESS, count(*) CNT FROM history where bef is null AND process_id = 'STEP1' AND P2 = 'STEP2' AND P3 = 'STEP3' AND P4 = 'STEP4' AND P5 = 'STEP5'
        ) 
        select PROCESS, CNT FROM result  where process is NOT NULL order by 1
        ;
提出情報
提出日時2023/12/15 16:13:24
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者Kojiron
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量98 MB
メッセージ
テストケース(通過数/総数)
3/4
状態
メモリ使用量
データパターン1
AC
98 MB
データパターン2
AC
88 MB
データパターン3
AC
86 MB
データパターン4
WA
85 MB