ソースコード
WITH t1 AS (SELECT lo.SESSION_ID, lo.PROCESS_ID, 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)
   , t2 AS (SELECT DISTINCT t1.SESSION_ID, t1.PROCESS_ID
            FROM t1
                 LEFT JOIN PROCESS_LOG log ON log.session_id = t1.session_id AND log.EX_TIMESTAMP = t1.pre_t
            WHERE ((t1.PROCESS_ID == 'STEP1' AND t1.pre_t IS NULL) OR (
                CAST(SUBSTR(t1.PROCESS_ID, 5, 1) AS integer) - 1 == CAST(SUBSTR(log.PROCESS_ID, 5, 1) AS integer)
                )))

SELECT PROCESS_ID PROCESS
     , COUNT(*) CNT
FROM (SELECT t2.SESSION_ID
           , t2.PROCESS_ID
           , COUNT(tmp.PROCESS_ID) cnt
      FROM t2
           LEFT JOIN t2 tmp ON tmp.SESSION_ID = t2.SESSION_ID AND t2.PROCESS_ID >= tmp.PROCESS_ID
      GROUP BY t2.SESSION_ID, t2.PROCESS_ID)
WHERE CAST(SUBSTR(PROCESS_ID, 5, 1) AS integer) = cnt
GROUP BY PROCESS_ID
ORDER BY 1
;
提出情報
提出日時2024/06/16 04:00:40
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者pp1mqa6hkm
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/4
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
84 MB
データパターン3
AC
85 MB
データパターン4
WA
84 MB