ソースコード
SELECT
'STEP1' as PROCESS_ID
,COUNT(*)-SUM(cnt)
FROM 
(
    SELECT
    a.SESSION_ID
    ,MAX(CASE WHEN a.EX_TIMESTAMP>b.EX_TIMESTAMP THEN 1 ELSE 0 END) as cnt
    FROM
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID='STEP1'
    )a
    LEFT OUTER JOIN
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID!='STEP1'
    )b
    ON
    a.SESSION_ID=b.SESSION_ID
    GROUP BY 
    a.SESSION_ID
)c
UNION
SELECT
'STEP2'
,COUNT(*)-SUM(cnt)
FROM 
(
    SELECT
    a.SESSION_ID
    ,MAX(CASE 
    WHEN a.EX_TIMESTAMP>b.EX_TIMESTAMP THEN 1 
    WHEN a.EX_TIMESTAMP<c.EX_TIMESTAMP THEN 1
    ELSE 0 END) as cnt
    FROM
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID='STEP2'
    )a
    LEFT OUTER JOIN
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID IN ('STEP3','STEP4','STEP5')
    )b
    ON
    a.SESSION_ID=b.SESSION_ID
    INNER JOIN
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID IN ('STEP1')    
    )c
    ON
    a.SESSION_ID=c.SESSION_ID
    GROUP BY 
    a.SESSION_ID
)d
UNION
SELECT
'STEP3'
,COUNT(*)-SUM(cnt)
FROM 
(
    SELECT
    a.SESSION_ID
    ,MAX(CASE 
    WHEN a.EX_TIMESTAMP>b.EX_TIMESTAMP THEN 1 
    WHEN a.EX_TIMESTAMP<c.EX_TIMESTAMP THEN 1
    ELSE 0 END) as cnt
    FROM
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID='STEP3'
    )a
    LEFT OUTER JOIN
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID IN ('STEP4','STEP5')
    )b
    ON
    a.SESSION_ID=b.SESSION_ID
    INNER JOIN
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID IN ('STEP1','STEP2')    
    )c
    ON
    a.SESSION_ID=c.SESSION_ID
    GROUP BY 
    a.SESSION_ID
)d
UNION
SELECT
'STEP4'
,COUNT(*)-SUM(cnt)
FROM 
(
    SELECT
    a.SESSION_ID
    ,MAX(CASE 
    WHEN a.EX_TIMESTAMP>b.EX_TIMESTAMP THEN 1 
    WHEN a.EX_TIMESTAMP<c.EX_TIMESTAMP THEN 1
    ELSE 0 END) as cnt
    FROM
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID='STEP4'
    )a
    LEFT OUTER JOIN
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID IN ('STEP5')
    )b
    ON
    a.SESSION_ID=b.SESSION_ID
    INNER JOIN
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID IN ('STEP1','STEP2','STEP3')    
    )c
    ON
    a.SESSION_ID=c.SESSION_ID
    GROUP BY 
    a.SESSION_ID
)d
UNION
SELECT
'STEP5'
,COUNT(*)-SUM(cnt)
FROM 
(
    SELECT
    a.SESSION_ID
    ,MAX(CASE 
    WHEN a.EX_TIMESTAMP>b.EX_TIMESTAMP THEN 1 
    WHEN a.EX_TIMESTAMP<c.EX_TIMESTAMP THEN 1
    ELSE 0 END) as cnt
    FROM
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID='STEP5'
    )a
    INNER JOIN
    (
        select *
        from PROCESS_LOG
        where PROCESS_ID IN ('STEP1','STEP2','STEP3','STEP4')    
    )c
    ON
    a.SESSION_ID=c.SESSION_ID
    GROUP BY 
    a.SESSION_ID
)d
ORDER BY 
PROCESS_ID
提出情報
提出日時2023/12/16 16:41:20
コンテスト第10回 SQLコンテスト
問題顧客行動分析
受験者FunSQL
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量85 MB
メッセージ
SQLITE_ERROR: no such column: b.EX_TIMESTAMP
テストケース(通過数/総数)
0/4
状態
メモリ使用量
データパターン1
RE
85 MB
データパターン2
RE
83 MB
データパターン3
RE
85 MB
データパターン4
RE
83 MB