ソースコード
with tmp as (
    select 
        SESSION_ID,
        process_id,
        rank() over(partition by SESSION_ID order by EX_TIMESTAMP ) as NO
    from process_log
),
tmp1 as (
    select
        SESSION_ID,
        process_id,
        no,
        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,
        process_id,
        min(no) as minno
    from tmp1
    where flag=0
    group by session_id
    order by session_id
)
select 
    tmp1.process_id as PROCESS,
    count(
        distinct 
            case 
                when cast(substr(tmp1.process_id,5,1) as int)<minno 
                    or tmp2.session_id is null 
                    then tmp1.session_id
            end ) as CNT
from tmp1
left outer join tmp2
on tmp1.session_id=tmp2.session_id
where flag=1
group by tmp1.process_id
order by process;

            
提出情報
提出日時2024/12/23 22:05:37
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者kate
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量88 MB
メッセージ
テストケース(通過数/総数)
3/4
状態
メモリ使用量
データパターン1
AC
88 MB
データパターン2
AC
85 MB
データパターン3
AC
87 MB
データパターン4
WA
85 MB