ソースコード
SELECT PROCESS_ID AS PROCESS,
       SUM(CNT) AS CNT
  FROM (SELECT SESSION_ID, 
               PROCESS_ID,
               USER_ID,
               EX_TIMESTAMP,
               CASE
                 WHEN PROCESS_ID = 'STEP5' AND LAG(PROCESS_ID, 1) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) = 'STEP4' AND LAG(PROCESS_ID, 2) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) = 'STEP3' AND LAG(PROCESS_ID, 3) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) = 'STEP2' AND LAG(PROCESS_ID, 4) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) = 'STEP1' AND LAG(PROCESS_ID, 5) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) IS NULL THEN '1'
                 WHEN PROCESS_ID = 'STEP4' AND LAG(PROCESS_ID, 1) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) = 'STEP3' AND LAG(PROCESS_ID, 2) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) = 'STEP2' AND LAG(PROCESS_ID, 3) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) = 'STEP1' AND LAG(PROCESS_ID, 4) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) IS NULL THEN '1'
                 WHEN PROCESS_ID = 'STEP3' AND LAG(PROCESS_ID, 1) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) = 'STEP2' AND LAG(PROCESS_ID, 2) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) = 'STEP1' AND LAG(PROCESS_ID, 3) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) IS NULL THEN '1'
                 WHEN PROCESS_ID = 'STEP2' AND LAG(PROCESS_ID, 1) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) = 'STEP1' AND LAG(PROCESS_ID, 2) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) IS NULL THEN '1'
                 WHEN PROCESS_ID = 'STEP1' AND LAG(PROCESS_ID, 1) over (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) IS NULL THEN '1'
                 ELSE '0'
               END AS CNT
          FROM PROCESS_LOG
        )
 GROUP BY PROCESS_ID
 ORDER BY PROCESS_ID
提出情報
提出日時2023/12/20 09:11:07
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者test
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量88 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
88 MB
データパターン2
AC
84 MB
データパターン3
AC
86 MB
データパターン4
AC
84 MB