ソースコード
WITH SUB1 AS (SELECT SESSION_ID, PROCESS_ID,
RANK() OVER(PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) AS RANK
FROM PROCESS_LOG
ORDER BY SESSION_ID),
SUB2 AS (SELECT SESSION_ID,
MIN(RANK) AS MIN
FROM SUB1
WHERE CAST(SUBSTR(PROCESS_ID, 5, 1) AS INTEGER) != RANK
GROUP BY SESSION_ID)
SELECT PROCESS_ID AS PROCESS,
COUNT(DISTINCT CASE WHEN CAST(SUBSTR(SUB1.PROCESS_ID, 5, 1) AS INTEGER) < SUB2.MIN
OR SUB2.MIN IS NULL
THEN SUB1.SESSION_ID END) AS CNT
FROM SUB1
LEFT JOIN SUB2
ON SUB1.SESSION_ID = SUB2.SESSION_ID
GROUP BY PROCESS_ID
ORDER BY PROCESS_ID
提出情報
提出日時2024/06/20 23:19:19
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者yanagiguchi
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
AC
84 MB
データパターン3
AC
85 MB
データパターン4
AC
85 MB