ソースコード
WITH P1 as (
    SELECT * FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP1'
), P2 as (
    SELECT * FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP2'
), P3 as (
    SELECT * FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP3'
), P4 as (
    SELECT * FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP4'
), P5 as (
    SELECT * FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP5'
), A2 as (
    SELECT COUNT(*) CNT
    FROM P1
    JOIN P2 ON P1.SESSION_ID = P2.SESSION_ID AND P1.EX_TIMESTAMP < P2.EX_TIMESTAMP
), A3 as (
    SELECT COUNT(*) CNT
    FROM P1
    JOIN P2 ON P1.SESSION_ID = P2.SESSION_ID AND P1.EX_TIMESTAMP < P2.EX_TIMESTAMP
    JOIN P3 ON P2.SESSION_ID = P3.SESSION_ID AND P2.EX_TIMESTAMP < P3.EX_TIMESTAMP
), A4 as (
    SELECT COUNT(*) CNT
    FROM P1
    JOIN P2 ON P1.SESSION_ID = P2.SESSION_ID AND P1.EX_TIMESTAMP < P2.EX_TIMESTAMP
    JOIN P3 ON P2.SESSION_ID = P3.SESSION_ID AND P2.EX_TIMESTAMP < P3.EX_TIMESTAMP
    JOIN P4 ON P3.SESSION_ID = P4.SESSION_ID AND P3.EX_TIMESTAMP < P4.EX_TIMESTAMP
), A5 as (
    SELECT COUNT(*) CNT
    FROM P1
    JOIN P2 ON P1.SESSION_ID = P2.SESSION_ID AND P1.EX_TIMESTAMP < P2.EX_TIMESTAMP
    JOIN P3 ON P2.SESSION_ID = P3.SESSION_ID AND P2.EX_TIMESTAMP < P3.EX_TIMESTAMP
    JOIN P4 ON P3.SESSION_ID = P4.SESSION_ID AND P3.EX_TIMESTAMP < P4.EX_TIMESTAMP
    JOIN P5 ON P4.SESSION_ID = P5.SESSION_ID AND P4.EX_TIMESTAMP < P5.EX_TIMESTAMP
)

      SELECT 'STEP1' PROCESS, (SELECT COUNT(*) FROM P1) CNT
UNION SELECT 'STEP2' PROCESS, (SELECT CNT FROM A2) CNT
UNION SELECT 'STEP3' PROCESS, (SELECT CNT FROM A3) CNT
UNION SELECT 'STEP4' PROCESS, (SELECT CNT FROM A4) CNT
UNION SELECT 'STEP5' PROCESS, (SELECT CNT FROM A5) CNT
提出情報
提出日時2023/12/17 19:38:22
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者mine
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量89 MB
メッセージ
テストケース(通過数/総数)
1/4
状態
メモリ使用量
データパターン1
WA
86 MB
データパターン2
WA
85 MB
データパターン3
WA
89 MB
データパターン4
AC
86 MB