ソースコード
WITH t1 AS (SELECT lo.SESSION_ID, lo.PROCESS_ID, lo.EX_TIMESTAMP, MAX(lo2.EX_TIMESTAMP) pre_t
            FROM PROCESS_LOG lo
                 LEFT JOIN PROCESS_LOG lo2 ON lo.SESSION_ID = lo2.SESSION_ID AND lo.EX_TIMESTAMP > lo2.EX_TIMESTAMP
            GROUP BY lo.SESSION_ID, lo.PROCESS_ID, lo.EX_TIMESTAMP)
   , t2 AS (SELECT t1.*, 1 step
            FROM t1
            WHERE PROCESS_ID = 'STEP1'
              AND pre_t IS NULL
            UNION ALL
            SELECT t1.*, t2.step + 1
            FROM t1
                 JOIN t2 ON t1.SESSION_ID = t2.SESSION_ID AND t1.PROCESS_ID = 'STEP' || (t2.step + 1) AND t1.pre_t = t2.EX_TIMESTAMP
            WHERE step < 5)
   , seq AS (SELECT 1 AS no UNION ALL SELECT no + 1 AS no FROM SEQ WHERE no + 1 <= 5)
SELECT 'STEP' || seq.no PROCESS, COUNT(session_id) CNT
FROM seq
     LEFT JOIN t2 ON 'STEP' || seq.no = t2.PROCESS_ID
GROUP BY seq.no
ORDER BY 1
提出情報
提出日時2024/06/16 04:45:12
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者pp1mqa6hkm
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
84 MB
データパターン3
AC
86 MB
データパターン4
AC
84 MB