ソースコード
with added as (
    select
        item_code,
        item_name,
        'ADDED' as COMP_RSLT 
    from item
    where 
        not exists(
            select *
            from item_history as h
            where item.item_code = h.item_code
        )
),
deleted as (
    select
        item_code,
        item_name,
        'DELETED' as COMP_RSLT 
    from item_history as h
    where 
        not exists(
            select *
            from item
            where item.item_code = h.item_code
        )

),
updated as (
    select
        item.item_code,
        item.item_name,
        'UPDATED' as COMP_RSLT 
    from item
        inner join item_history
            on item.item_code = item_history.item_code
                and item.USER_UPDATE_DATETIME > item_history.USER_UPDATE_DATETIME
),
temp as (
    select * from added
    union all
    select * from deleted
    union all
    select * from updated
)
select 
    item_code as CODE,
    item_name as NAME,
    COMP_RSLT
from temp
order by CODE desc
;
提出情報
提出日時2024/04/20 14:11:39
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者Udwei22
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
86 MB
データパターン3
AC
84 MB