ソースコード
with deleted as (
    select
        ITEM_CODE as CODE
        , ITEM_NAME as NAME
        , 'DELETED' as COMP_RSLT
    from
        ITEM_HISTORY ih
    where not exists(
            select 1 from ITEM i where ih.ITEM_CODE = i.ITEM_CODE
        )
), added as (
    select
        ITEM_CODE as CODE
        , ITEM_NAME as NAME
        , 'ADDED' as COMP_RSLT
    from
        ITEM i
    where not exists(
            select 1 from ITEM_HISTORY ih where i.ITEM_CODE = ih.ITEM_CODE
        )
), updated as (
    select
        i.ITEM_CODE as CODE
        , i.ITEM_NAME as NAME
        , 'UPDATED' as COMP_RSLT
    from
        ITEM i
        inner join
            ITEM_HISTORY ih
        on
            i.ITEM_CODE = ih.ITEM_CODE
            and i.USER_UPDATE_DATETIME != ih.USER_UPDATE_DATETIME
)

select
    CODE
    , NAME
    , COMP_RSLT
from
    (
        select * from deleted
        union all
        select * from added
        union all
        select * from updated
    )
order by
    CODE desc
;
提出情報
提出日時2024/04/22 14:13:29
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者odsgym
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
84 MB
データパターン3
AC
83 MB