コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
WITH T1 AS(
SELECT
MAX(P1.SESSION_ID) AS SESSION_ID,
MAX(CAST(SUBSTR(P1.PROCESS_ID, -1) AS INTEGER)) AS PROCESS_ID
FROM
PROCESS_LOG AS P1
CROSS JOIN
PROCESS_LOG AS P2
WHERE
P1.SESSION_ID = P2.SESSION_ID
GROUP BY
P1.SESSION_ID,
P1.PROCESS_ID
HAVING
(
MAX(
CASE
WHEN P2.PROCESS_ID < P1.PROCESS_ID THEN P2.EX_TIMESTAMP
ELSE NULL
END
) IS NULL OR MAX(P1.EX_TIMESTAMP) > MAX(
CASE
WHEN P2.PROCESS_ID < P1.PROCESS_ID THEN P2.EX_TIMESTAMP
ELSE NULL
END
)
) AND (
MIN(
CASE
WHEN P2.PROCESS_ID > P1.PROCESS_ID THEN P2.EX_TIMESTAMP
ELSE NULL
END
) IS NULL OR MAX(P1.EX_TIMESTAMP) < MIN(
CASE
WHEN P2.PROCESS_ID > P1.PROCESS_ID THEN P2.EX_TIMESTAMP
ELSE NULL
END
)
)
), T2 AS(
SELECT
MAX(P1.SESSION_ID) AS SESSION_ID,
MAX(P1.PROCESS_ID) AS PROCESS_ID
FROM
T1 AS P1
CROSS JOIN
T1 AS P2
WHERE
P1.SESSION_ID = P2.SESSION_ID
GROUP BY
P1.SESSION_ID,
P1.PROCESS_ID
HAVING
MAX(P1.PROCESS_ID) = SUM(
CASE
WHEN P2.PROCESS_ID <= P1.PROCESS_ID THEN 1
ELSE 0
END
)
), T3 AS(
SELECT
MAX(PROCESS_ID) AS PROCESS_ID,
COUNT(*) AS CNT
FROM
T2
GROUP BY
PROCESS_ID
ORDER BY
PROCESS_ID ASC
), T4 AS(
SELECT
1 AS PROCESS_ID
UNION ALL
SELECT
PROCESS_ID + 1 AS PROCESS_ID
FROM T4
WHERE
PROCESS_ID < 5
), T5 AS(
SELECT
'STEP' || T4.PROCESS_ID AS PROCESS,
CASE
WHEN T3.CNT IS NULL THEN 0
ELSE T3.CNT
END AS CNT
FROM
T4
LEFT OUTER JOIN
T3 ON T4.PROCESS_ID = T3.PROCESS_ID
)
SELECT
*
FROM
T5
提出情報
提出日時 | 2023/12/17 10:58:42 |
コンテスト | 第10回 SQLコンテスト |
問題 | 顧客行動分析 |
受験者 | tokusakurai |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 87 MB |
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
87 MB
データパターン2
AC
87 MB
データパターン3
AC
87 MB
データパターン4
AC
85 MB