ソースコード
with sub1 as (
    select 
        session_id
        , process_id
        , rank() over (partition by session_id order by ex_timestamp) as rank
    from process_log
    order by session_id asc, ex_timestamp asc
),
sub2 as (
    select session_id, min(rank) as min
    from sub1
    where cast(substr(sub1.process_id, 5, 1) as int) != rank
    group by session_id
)
select 
    process_id as PROCESS
    , count(distinct case when cast(substr(sub1.process_id, 5, 1) as int)<sub2.min
                                or sub2.min is null then sub1.session_id end) as CNT
from sub1 
left join sub2 on sub1.session_id=sub2.session_id
group by process_id
order by process_id;
提出情報
提出日時2024/05/10 16:44:09
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者sjty9561
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
83 MB
データパターン3
AC
85 MB
データパターン4
AC
83 MB