ソースコード
WITH STEP1 AS (
    SELECT
        SESSION_ID
        , EX_TIMESTAMP
    FROM
        PROCESS_LOG
    WHERE
        PROCESS_ID = 'STEP1'
),
STEP1AFR AS (
    SELECT
        a.SESSION_ID
        , ROW_NUMBER() OVER (PARTITION BY a.SESSION_ID ORDER BY a.SESSION_ID, a.EX_TIMESTAMP) AS RNUM
        , PROCESS_ID
        , CAST(REPLACE(PROCESS_ID, 'STEP', '') AS INT) AS PROCNUM
        , a.EX_TIMESTAMP
    FROM
        PROCESS_LOG a
        INNER JOIN STEP1 b ON
            a.SESSION_ID = b.SESSION_ID
            AND a.EX_TIMESTAMP >= b.EX_TIMESTAMP
),
MINRNUM AS (
    SELECT
        SESSION_ID
        , MIN(RNUM) AS MINRNUM
    FROM
        STEP1AFR
    WHERE
        RNUM != PROCNUM
    GROUP BY SESSION_ID
)
SELECT
    'STEP' || PROCNUM AS PROCESS
    , COUNT(DISTINCT
        CASE WHEN MINRNUM IS NULL OR MINRNUM > RNUM THEN a.SESSION_ID END
    ) AS CNT
FROM
    STEP1AFR a
    LEFT JOIN MINRNUM b ON
        a.SESSION_ID = b.SESSION_ID
GROUP BY
    PROCNUM
ORDER BY
    PROCNUM
;
提出情報
提出日時2024/02/09 16:19:01
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者SQL2022
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量87 MB
メッセージ
テストケース(通過数/総数)
3/4
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
84 MB
データパターン3
WA
87 MB
データパターン4
AC
84 MB