ソースコード
WITH OrderedProcesses AS (
    SELECT
        SESSION_ID,
        PROCESS_ID,
        EX_TIMESTAMP,
        ROW_NUMBER() OVER (PARTITION BY SESSION_ID ORDER BY EX_TIMESTAMP) AS StepOrder
    FROM
        PROCESS_LOG
    WHERE
        PROCESS_ID IN ('STEP1', 'STEP2', 'STEP3', 'STEP4', 'STEP5')
),
ValidSessions AS (
    SELECT
        SESSION_ID
    FROM
        OrderedProcesses
    GROUP BY
        SESSION_ID
    HAVING
        MAX(CASE WHEN PROCESS_ID = 'STEP1' THEN StepOrder ELSE 0 END) = 1 OR
        MAX(CASE WHEN PROCESS_ID = 'STEP2' THEN StepOrder ELSE 0 END) IN (0, 2) OR
        MAX(CASE WHEN PROCESS_ID = 'STEP3' THEN StepOrder ELSE 0 END) IN (0, 3) OR
        MAX(CASE WHEN PROCESS_ID = 'STEP4' THEN StepOrder ELSE 0 END) IN (0, 4) OR
        MAX(CASE WHEN PROCESS_ID = 'STEP5' THEN StepOrder ELSE 0 END) IN (0, 5)
)
SELECT
    p.PROCESS_ID,
    COUNT(DISTINCT p.SESSION_ID) AS SessionCount
FROM
    OrderedProcesses p
INNER JOIN
    ValidSessions v ON p.SESSION_ID = v.SESSION_ID
GROUP BY
    p.PROCESS_ID
ORDER BY
    p.PROCESS_ID;
提出情報
提出日時2023/12/16 17:19:51
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者104_rose
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
0/4
状態
メモリ使用量
データパターン1
WA
84 MB
データパターン2
WA
84 MB
データパターン3
WA
86 MB
データパターン4
WA
84 MB