ソースコード
WITH T1 AS(
    SELECT
        ITEM.ITEM_CODE AS CODE,
        ITEM.ITEM_NAME AS NAME,
        ITEM.USER_UPDATE_DATETIME AS TIME,
        ITEM_HISTORY.USER_UPDATE_DATETIME AS TIME_HISTORY
    FROM
        ITEM
    LEFT OUTER JOIN
        ITEM_HISTORY ON ITEM.ITEM_CODE = ITEM_HISTORY.ITEM_CODE
), T2 AS(
    SELECT
        CODE,
        NAME,
        CASE
            WHEN TIME_HISTORY IS NULL THEN 'ADDED'
            WHEN TIME != TIME_HISTORY THEN 'UPDATED'
            ELSE 'NO'
        END AS COMP_RSLT
    FROM
        T1
    WHERE
        COMP_RSLT != 'NO'
), T3 AS(
    SELECT
        ITEM_HISTORY.ITEM_CODE AS CODE,
        ITEM_HISTORY.ITEM_NAME AS NAME,
        ITEM.USER_UPDATE_DATETIME AS TIME,
        ITEM_HISTORY.USER_UPDATE_DATETIME AS TIME_HISTORY
    FROM
        ITEM_HISTORY
    LEFT OUTER JOIN
        ITEM ON ITEM.ITEM_CODE = ITEM_HISTORY.ITEM_CODE
), T4 AS(
    SELECT
        CODE,
        NAME,
        CASE
            WHEN TIME IS NULL THEN 'DELETED'
            ELSE 'NO'
        END AS COMP_RSLT
    FROM
        T3
    WHERE
        COMP_RSLT != 'NO'
), T5 AS(
    SELECT
        CODE,
        NAME,
        COMP_RSLT
    FROM
        T2
    UNION ALL
    SELECT
        CODE,
        NAME,
        COMP_RSLT
    FROM
        T4
    ORDER BY
        CODE DESC
)

SELECT
    *
FROM
    T5
提出情報
提出日時2024/04/21 12:16:35
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者tokusakurai
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
83 MB
データパターン3
AC
84 MB