ソースコード
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 ASC,
            EX_TIMESTAMP ASC
    ),
    sub2 AS (
        SELECT
            SESSION_ID,
            MIN(RANK) AS MIN
        FROM
            sub1
        WHERE
            CAST(SUBSTR (SUB1.PROCESS_ID, 5, 1) AS INT) <> RANK
        GROUP BY
            SESSION_ID
    )
SELECT
    PROCESS_ID AS PROCESS,
    COUNT(
        DISTINCT CASE
            WHEN CAST(SUBSTR (sub1.PROCESS_ID, 5, 1) AS INT) < sub2.MIN
            OR sub2.MIN IS NULL THEN sub1.SESSION_ID
        END
    ) AS CNT
FROM
    sub1
    LEFT OUTER JOIN sub2 ON sub1.SESSION_ID = sub2.SESSION_ID
GROUP BY
    PROCESS_ID
ORDER BY
    PROCESS_ID ASC;
提出情報
提出日時2024/06/27 19:37:43
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者kwm_t
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
84 MB
データパターン3
AC
85 MB
データパターン4
AC
84 MB