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