ソースコード
with tmp as (
    select 
        SESSION_ID,
        process_id,
        ex_timestamp,
        rank() over(partition by SESSION_ID order by EX_TIMESTAMP ) as NO
    from process_log
),
tmp1 as (
    select
        SESSION_ID,
        process_id,
        no,
        ex_timestamp,
        case 
            when process_id='STEP1' and NO=1 then 1
            when process_id='STEP2' and NO=2 then 1
            when process_id='STEP3' and NO=3 then 1
            when process_id='STEP4' and NO=4 then 1
            when process_id='STEP5' and NO=5 then 1
            else 0
        end as flag
    from tmp
),
tmp2 as (
    select 
        session_id,
        min(ex_timestamp) over(partition by session_id order by ex_timestamp) as min_timestamp,
        /*min(process_id) as minid,*/
        process_id,
        no
    from tmp1
    where flag=0
    group by session_id
    order by session_id
),
tmp3 as (
    select
        tmp1.session_id,
        tmp1.process_id,
        case 
            when tmp2.session_id=tmp1.session_id and tmp1.ex_timestamp>=min_timestamp then 0
            else 1
        end flag1,
        tmp1.no,
        flag
    from tmp1
    left outer join tmp2
    on tmp1.session_id=tmp2.session_id
    where flag=1 and flag1=1
)
select 
    process_id as PROCESS,
    count(session_id) as CNT
from tmp3
group by process_id
order by process;
提出情報
提出日時2024/12/23 20:20:15
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者kate
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量87 MB
メッセージ
テストケース(通過数/総数)
3/4
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
87 MB
データパターン3
AC
86 MB
データパターン4
WA
85 MB