ソースコード
SELECT
    CODE,
    NAME,
    CASE CHECKFLG
        WHEN '1' THEN 'ADDED'
        WHEN '2' THEN 'UPDATED'
        WHEN '3' THEN 'DELETED'
    END AS COMP_RSLT
FROM
    (
        SELECT
            CODE,
            NAME,
            CHECKFLG
        FROM
            (
                SELECT
                    add1.ITEM_CODE AS CODE,
                    add1.ITEM_NAME AS NAME,
                    '1' AS CHECKFLG
                FROM
                    ITEM add1
                    LEFT JOIN ITEM_HISTORY add2 ON add1.ITEM_CODE = add2.ITEM_CODE
                WHERE
                    add2.ITEM_CODE IS NULL
                UNION
                SELECT
                    upd1.ITEM_CODE AS CODE,
                    upd1.ITEM_NAME AS NAME,
                    '2' AS CHECKFLG
                FROM
                    ITEM AS upd1
                    LEFT JOIN ITEM_HISTORY upd2 ON upd1.ITEM_CODE = upd2.ITEM_CODE
                WHERE
                    upd1.USER_UPDATE_DATETIME <> upd2.USER_UPDATE_DATETIME
                UNION
                SELECT
                    del2.ITEM_CODE AS CODE,
                    del2.ITEM_NAME AS NAME,
                    '3' AS CHECKFLG
                FROM
                    ITEM_HISTORY AS del2
                    LEFT JOIN ITEM del1 ON del2.ITEM_CODE = del1.ITEM_CODE
                WHERE
                    del1.ITEM_CODE IS NULL
            )
        GROUP BY
            CODE
    )
ORDER BY
    CODE DESC
提出情報
提出日時2024/06/04 14:08:27
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者nocopylight
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量88 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
AC
88 MB
データパターン3
AC
88 MB