ソースコード
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 ST2 IS NOT NULL AND (ST3 IS NULL OR ST2 < ST3) AND (ST4 IS NULL OR ST2 < ST4) AND (ST5 IS NULL OR ST2 < ST5)

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 ST2 IS NOT NULL AND (ST3 IS NULL OR ST2 < ST3) AND (ST4 IS NULL OR ST2 < ST4) AND (ST5 IS NULL OR ST2 < ST5)
AND ST3 IS NOT NULL AND (ST4 IS NULL OR ST3 < ST4) AND (ST5 IS NULL OR ST3 < ST5)

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 ST2 IS NOT NULL AND (ST3 IS NULL OR ST2 < ST3) AND (ST4 IS NULL OR ST2 < ST4) AND (ST5 IS NULL OR ST2 < ST5)
AND ST3 IS NOT NULL AND (ST4 IS NULL OR ST3 < ST4) AND (ST5 IS NULL OR ST3 < ST5)
AND ST4 IS NOT NULL AND (ST5 IS NULL OR ST4 < ST5)

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 ST2 IS NOT NULL AND (ST3 IS NULL OR ST2 < ST3) AND (ST4 IS NULL OR ST2 < ST4) AND (ST5 IS NULL OR ST2 < ST5)
AND ST3 IS NOT NULL AND (ST4 IS NULL OR ST3 < ST4) AND (ST5 IS NULL OR ST3 < ST5)
AND ST4 IS NOT NULL AND (ST5 IS NULL OR ST4 < ST5)
AND ST5 IS NOT NULL
;
提出情報
提出日時2023/12/21 11:03:51
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者a01sa01to
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量91 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
90 MB
データパターン2
AC
89 MB
データパターン3
AC
91 MB
データパターン4
AC
89 MB