コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
WITH P as (
SELECT SESSION_ID, MIN(EX_TIMESTAMP) EX_TIMESTAMP FROM PROCESS_LOG GROUP BY SESSION_ID
), P1 as (
SELECT *
FROM PROCESS_LOG PL
JOIN P ON PL.SESSION_ID = P.SESSION_ID AND PL.EX_TIMESTAMP = P.EX_TIMESTAMP
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(P1.SESSION_ID) CNT
FROM P1
JOIN P2 ON P1.SESSION_ID = P2.SESSION_ID AND P1.EX_TIMESTAMP < P2.EX_TIMESTAMP
LEFT JOIN P3 ON P2.SESSION_ID = P3.SESSION_ID
LEFT JOIN P4 ON P2.SESSION_ID = P4.SESSION_ID
LEFT JOIN P5 ON P2.SESSION_ID = P5.SESSION_ID
WHERE
(P3.EX_TIMESTAMP IS NULL OR P2.EX_TIMESTAMP < P3.EX_TIMESTAMP)
AND (P4.EX_TIMESTAMP IS NULL OR P2.EX_TIMESTAMP < P4.EX_TIMESTAMP)
AND (P5.EX_TIMESTAMP IS NULL OR P2.EX_TIMESTAMP < P5.EX_TIMESTAMP)
), A3 as (
SELECT COUNT(P1.SESSION_ID) 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
LEFT JOIN P4 ON P3.SESSION_ID = P4.SESSION_ID
LEFT JOIN P5 ON P3.SESSION_ID = P5.SESSION_ID
WHERE
(P4.EX_TIMESTAMP IS NULL OR P3.EX_TIMESTAMP < P4.EX_TIMESTAMP)
AND (P5.EX_TIMESTAMP IS NULL OR P3.EX_TIMESTAMP < P5.EX_TIMESTAMP)
), A4 as (
SELECT COUNT(P1.SESSION_ID) 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
LEFT JOIN P5 ON P4.SESSION_ID = P5.SESSION_ID
WHERE
(P5.EX_TIMESTAMP IS NULL OR P4.EX_TIMESTAMP < P5.EX_TIMESTAMP)
), A5 as (
SELECT COUNT(P1.SESSION_ID) 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(SESSION_ID) 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:49:10 |
コンテスト | 第10回 SQLコンテスト |
問題 | 顧客行動分析 |
受験者 | mine |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 91 MB |
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
88 MB
データパターン2
AC
91 MB
データパターン3
AC
88 MB
データパターン4
AC
89 MB