ソースコード
with w as (
  select
    count(p1.SESSION_ID) as p1,
    count(p2.SESSION_ID) as p2,
    count(p3.SESSION_ID) as p3,
    count(p4.SESSION_ID) as p4,
    count(p5.SESSION_ID) as p5
  from PROCESS_LOG as p1
    left join PROCESS_LOG as p2 on p2.SESSION_ID = p1.SESSION_ID and p2.PROCESS_ID = 'STEP2' and p1.EX_TIMESTAMP < p2.EX_TIMESTAMP
    left join PROCESS_LOG as p3 on p3.SESSION_ID = p1.SESSION_ID and p3.PROCESS_ID = 'STEP3' and p2.EX_TIMESTAMP < p3.EX_TIMESTAMP
    left join PROCESS_LOG as p4 on p4.SESSION_ID = p1.SESSION_ID and p4.PROCESS_ID = 'STEP4' and p3.EX_TIMESTAMP < p4.EX_TIMESTAMP
    left join PROCESS_LOG as p5 on p5.SESSION_ID = p1.SESSION_ID and p5.PROCESS_ID = 'STEP5' and p4.EX_TIMESTAMP < p5.EX_TIMESTAMP
  where p1.PROCESS_ID = 'STEP1'
  and not exists (
    select * from PROCESS_LOG p
    where p.SESSION_ID = p1.SESSION_ID
    and p.EX_TIMESTAMP < p1.EX_TIMESTAMP
    and p.PROCESS_ID <> p1.PROCESS_ID
)
)
select 'STEP1' as PROCESS, p1 as CNT from w union all
select 'STEP2' as PROCESS, p2 as CNT from w union all
select 'STEP3' as PROCESS, p3 as CNT from w union all
select 'STEP4' as PROCESS, p4 as CNT from w union all
select 'STEP5' as PROCESS, p5 as CNT from w
order by PROCESS asc
提出情報
提出日時2023/12/18 01:31:21
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者ngyuki
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量96 MB
メッセージ
テストケース(通過数/総数)
1/4
状態
メモリ使用量
データパターン1
WA
85 MB
データパターン2
WA
85 MB
データパターン3
WA
96 MB
データパターン4
AC
84 MB