ソースコード
WITH RECURSIVE PROCESS(PROCESS_NO) AS (
    SELECT              1 AS PROCESS_NO
    UNION ALL
    SELECT PROCESS_NO + 1 AS PROCESS_NO FROM PROCESS WHERE PROCESS_NO < 5
), PROCESS_LOG1 AS (
    SELECT
        SESSION_ID,
        PROCESS_ID,
        RANK() OVER (
            PARTITION BY SESSION_ID
            ORDER BY COALESCE(EX_TIMESTAMP, '2000-01-01 00:00:00') ASC
        ) AS TIMETAMP_NO
    FROM
        PROCESS_LOG
), PROCESS_LOG2 AS (
    SELECT
        PROCESS_LOG1.*,
        RANK() OVER (
            PARTITION BY SESSION_ID
            ORDER BY PROCESS_ID ASC
        ) AS PROCESS_NO
    FROM
        PROCESS_LOG1
    WHERE
        PROCESS_LOG1.PROCESS_ID = 'STEP' || TIMETAMP_NO
)
SELECT
    'STEP' || PROCESS.PROCESS_NO AS PROCESS,
    COALESCE(LOG.CNT, 0) AS CNT
FROM
    PROCESS
LEFT JOIN (
    SELECT
        PROCESS_NO,
        COUNT(*) AS CNT
    FROM
        PROCESS_LOG2
    WHERE
        PROCESS_LOG2.PROCESS_NO = PROCESS_LOG2.TIMETAMP_NO
    GROUP BY
        PROCESS_LOG2.PROCESS_ID
    ORDER BY
        PROCESS_LOG2.PROCESS_ID
) AS
    LOG ON
    LOG.PROCESS_NO = PROCESS.PROCESS_NO;
提出情報
提出日時2024/02/11 15:02:45
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者naoigcat
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
85 MB
データパターン3
AC
85 MB
データパターン4
AC
86 MB