ソースコード
with
    t as (
        select
            session_id
            ,process_id
            ,ex_timestamp
            ,rank() over (partition by session_id order by ex_timestamp) as ord
            ,cast(substr(process_id, 5, 1) as int) as step
        from
            process_log
        order by
            session_id
    )
    ,u as (
        select
            *
            ,case
                when ord = step then 1
                else 0
                end as flag
        from
            t
    )
    ,v as (
        select
            *
            ,sum(flag) over (partition by session_id order by ord) as judge
        from
            u
    )
    ,w as (
        select
            session_id
            ,process_id
            ,ex_timestamp
            ,max(ord) as reach
        from
            v
        group by
            1
    )

select
    'STEP1' as PROCESS
    ,count(session_id) as CNT
from
    w
where
    reach >= 1
union
select
    'STEP2' as PROCESS
    ,count(session_id) as CNT
from
    w
where
    reach >= 2
union
select
    'STEP3' as PROCESS
    ,count(session_id) as CNT
from
    w
where
    reach >= 3
union
select
    'STEP4' as PROCESS
    ,count(session_id) as CNT
from
    w
where
    reach >= 4
union
select
    'STEP5' as PROCESS
    ,count(session_id) as CNT
from
    w
where
    reach >= 5
提出情報
提出日時2023/12/15 23:24:44
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者takahirostone
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量87 MB
メッセージ
テストケース(通過数/総数)
0/4
状態
メモリ使用量
データパターン1
WA
85 MB
データパターン2
WA
86 MB
データパターン3
WA
87 MB
データパターン4
WA
84 MB