ソースコード
with base as (
select
    SESSION_ID
    ,cast(replace(PROCESS_ID,"STEP","") as int) as PROCESS_ID
    ,row_number() over (partition by SESSION_ID order by EX_TIMESTAMP) as PR_ORDER
    ,EX_TIMESTAMP
from
    PROCESS_LOG
)
,base2 as (
select
    SESSION_ID
    ,PROCESS_ID
    ,EX_TIMESTAMP
    ,row_number() over (partition by SESSION_ID order by EX_TIMESTAMP) as PR_ORDER2
from
    base
where
    PROCESS_ID = PR_ORDER
)
,base3 as (
select
    PROCESS_ID 
    ,count() as CNT
from
    base2
where
    PROCESS_ID = PR_ORDER2
group by 
    PROCESS_ID
order by
    PROCESS_ID
)
,proc as (
select 
    1 as PROCESS_ID
union all
select
    PROCESS_ID+1
from
    proc
where 
    PROCESS_ID<5
)
select
    "STEP"||p.PROCESS_ID as PROCESS
    ,coalesce(b.CNT,0) as CNT
from
    proc as p
    left join
    base3 as b
    on p.PROCESS_ID=b.PROCESS_ID
order by
    p.PROCESS_ID
提出情報
提出日時2024/03/14 16:13:45
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者gP2fWnUzTL
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
82 MB
データパターン3
AC
85 MB
データパターン4
AC
83 MB