ソースコード
SELECT 'STEP1' AS PROCESS, COUNT(*) AS CNT FROM (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST1 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP1'
) a
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST2 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP2'
) b
ON a.SESSION_ID = b.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST3 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP3'
) c
ON a.SESSION_ID = c.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST4 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP4'
) d
ON a.SESSION_ID = d.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST5 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP5'
) e
ON a.SESSION_ID = e.SESSION_ID
WHERE a.SESSION_ID NOT NULL AND (ST2 IS NULL OR ST1 < ST2) AND (ST3 IS NULL OR ST1 < ST3) AND (ST4 IS NULL OR ST1 < ST4) AND (ST5 IS NULL OR ST1 < ST5)

UNION

SELECT 'STEP2' AS PROCESS, COUNT(*) AS CNT FROM (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST1 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP1'
) a
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST2 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP2'
) b
ON a.SESSION_ID = b.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST3 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP3'
) c
ON a.SESSION_ID = c.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST4 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP4'
) d
ON a.SESSION_ID = d.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST5 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP5'
) e
ON a.SESSION_ID = e.SESSION_ID
WHERE a.SESSION_ID NOT NULL AND (ST2 IS NULL OR ST1 < ST2) AND (ST3 IS NULL OR ST1 < ST3) AND (ST4 IS NULL OR ST1 < ST4) AND (ST5 IS NULL OR ST1 < ST5)
AND ST1 < ST2


UNION

SELECT 'STEP3' AS PROCESS, COUNT(*) AS CNT FROM (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST1 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP1'
) a
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST2 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP2'
) b
ON a.SESSION_ID = b.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST3 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP3'
) c
ON a.SESSION_ID = c.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST4 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP4'
) d
ON a.SESSION_ID = d.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST5 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP5'
) e
ON a.SESSION_ID = e.SESSION_ID
WHERE a.SESSION_ID NOT NULL AND (ST2 IS NULL OR ST1 < ST2) AND (ST3 IS NULL OR ST1 < ST3) AND (ST4 IS NULL OR ST1 < ST4) AND (ST5 IS NULL OR ST1 < ST5)
AND ST1 < ST2 AND ST2 < ST3

UNION

SELECT 'STEP4' AS PROCESS, COUNT(*) AS CNT FROM (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST1 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP1'
) a
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST2 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP2'
) b
ON a.SESSION_ID = b.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST3 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP3'
) c
ON a.SESSION_ID = c.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST4 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP4'
) d
ON a.SESSION_ID = d.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST5 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP5'
) e
ON a.SESSION_ID = e.SESSION_ID
WHERE a.SESSION_ID NOT NULL AND (ST2 IS NULL OR ST1 < ST2) AND (ST3 IS NULL OR ST1 < ST3) AND (ST4 IS NULL OR ST1 < ST4) AND (ST5 IS NULL OR ST1 < ST5)
AND ST1 < ST2 AND ST2 < ST3 AND ST3 < ST4

UNION

SELECT 'STEP5' AS PROCESS, COUNT(*) AS CNT FROM (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST1 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP1'
) a
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST2 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP2'
) b
ON a.SESSION_ID = b.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST3 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP3'
) c
ON a.SESSION_ID = c.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST4 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP4'
) d
ON a.SESSION_ID = d.SESSION_ID
FULL OUTER JOIN (
    SELECT SESSION_ID, EX_TIMESTAMP AS ST5 FROM PROCESS_LOG WHERE PROCESS_ID = 'STEP5'
) e
ON a.SESSION_ID = e.SESSION_ID
WHERE a.SESSION_ID NOT NULL AND (ST2 IS NULL OR ST1 < ST2) AND (ST3 IS NULL OR ST1 < ST3) AND (ST4 IS NULL OR ST1 < ST4) AND (ST5 IS NULL OR ST1 < ST5)
AND ST1 < ST2 AND ST2 < ST3 AND ST3 < ST4 AND ST4 < ST5
;
提出情報
提出日時2023/12/16 13:43:53
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者a01sa01to
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量89 MB
メッセージ
テストケース(通過数/総数)
1/4
状態
メモリ使用量
データパターン1
WA
89 MB
データパターン2
WA
87 MB
データパターン3
WA
89 MB
データパターン4
AC
87 MB