ソースコード
WITH tmp_add 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
), tmp_del 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
), tmp_diff AS (
SELECT
    ITEM.ITEM_CODE AS CODE
    ,ITEM.ITEM_NAME AS NAME
    ,'UPDATED' AS COMP_RSLT
FROM
    ITEM
INNER JOIN
    ITEM_HISTORY
ON
    ITEM.ITEM_CODE = ITEM_HISTORY.ITEM_CODE
WHERE
    ITEM_HISTORY.USER_UPDATE_DATETIME <> ITEM.USER_UPDATE_DATETIME
)

SELECT * FROM tmp_add
UNION ALL
SELECT * FROM tmp_del
UNION ALL
SELECT * FROM tmp_diff
ORDER BY CODE DESC
提出情報
提出日時2024/07/18 10:21:51
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者mywk
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
83 MB
データパターン3
AC
83 MB