ソースコード
WITH added AS(
    SELECT
        ITEM.ITEM_CODE AS 'CODE',
        ITEM.ITEM_NAME AS 'NAME',
        'ADDED' AS 'COMP_RSLT'
    FROM
        ITEM
        LEFT JOIN ITEM_HISTORY ON ITEM.ITEM_CODE = ITEM_HISTORY.ITEM_CODE
    WHERE
        ITEM_HISTORY.ITEM_CODE IS NULL
),
updated AS(
    SELECT
        ITEM.ITEM_CODE AS 'CODE',
        ITEM.ITEM_NAME AS 'NAME',
        'UPDATED' AS 'COMP_RSLT'
    FROM
        ITEM
        JOIN ITEM_HISTORY ON ITEM.ITEM_CODE = ITEM_HISTORY.ITEM_CODE
    WHERE
        ITEM.USER_UPDATE_DATETIME <> ITEM_HISTORY.USER_UPDATE_DATETIME
),
deleted AS(
    SELECT
        ITEM_HISTORY.ITEM_CODE AS 'CODE',
        ITEM_HISTORY.ITEM_NAME AS 'NAME',
        'DELETED' AS 'COMP_RSLT'
    FROM
        ITEM_HISTORY
        LEFT JOIN ITEM ON ITEM.ITEM_CODE = ITEM_HISTORY.ITEM_CODE
    WHERE
        ITEM.ITEM_CODE IS NULL
)
SELECT
    *
FROM
    added
UNION
SELECT
    *
FROM
    deleted
UNION
SELECT
    *
FROM
    updated
ORDER BY
    CODE DESC
提出情報
提出日時2024/04/21 23:39:53
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者asd
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量83 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
83 MB
データパターン3
AC
83 MB