ソースコード
WITH STEP AS (SELECT SESSION_ID, PROCESS_ID AS P5,
  MIN(PROCESS_ID) OVER (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS P4,
  MIN(PROCESS_ID) OVER (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) AS P3,
  MIN(PROCESS_ID) OVER (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP ROWS BETWEEN 3 PRECEDING AND 3 PRECEDING) AS P2,
  MIN(PROCESS_ID) OVER (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP ROWS BETWEEN 4 PRECEDING AND 4 PRECEDING) AS P1
  FROM PROCESS_LOG
),
CC AS (SELECT SESSION_ID,
CASE WHEN P5 = 'STEP5' AND P4 = 'STEP4' AND P3 = 'STEP3' AND P2 = 'STEP2' AND P1 = 'STEP1' THEN 'STEP5'
WHEN P5 = 'STEP4' AND P4 = 'STEP3' AND P3 = 'STEP2' AND P2 = 'STEP1' AND P1 IS NULL THEN 'STEP4'
WHEN P5 = 'STEP3' AND P4 = 'STEP2' AND P3 = 'STEP1' AND P2 IS NULL AND P1 IS NULL THEN 'STEP3'
WHEN P5 = 'STEP2' AND P4 = 'STEP1' AND P3 IS NULL AND P2  IS NULL AND P1 IS NULL THEN 'STEP2'
WHEN P5 = 'STEP1' AND P4 IS NULL AND P3 IS NULL AND P2 IS NULL AND P1 IS NULL THEN 'STEP1'
ELSE NULL END AS PROCESS
FROM STEP)
SELECT PROCESS, COUNT(*) AS CNT FROM CC WHERE PROCESS IS NOT NULL GROUP BY PROCESS;
提出情報
提出日時2023/12/16 13:39:46
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者matsuu
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
3/4
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
84 MB
データパターン3
AC
86 MB
データパターン4
WA
85 MB