ソースコード
with ad as (
    select 
        it.ITEM_CODE as CODE,
        it.ITEM_NAME as NAME,
        'ADDED' as COMP_RSLT 
    from ITEM as it
    where
        not exists(
            select 
                it.ITEM_CODE as CODE,
                it.ITEM_NAME as NAME
            from ITEM_HISTORY as ith
            where
                it.ITEM_CODE = ith.ITEM_CODE
        )
), de as (
    select 
        ith.ITEM_CODE as CODE,
        ith.ITEM_NAME as NAME,
        'DELETED' as COMP_RSLT  
    from ITEM_HISTORY as ith
    where
        not exists(
            select 
                ith.ITEM_CODE as CODE,
                ith.ITEM_NAME as NAME
            from ITEM as it
            where
                it.ITEM_CODE = ith.ITEM_CODE
        )
), up as(
    select 
        it.ITEM_CODE as CODE,
        it.ITEM_NAME as NAME,
        'UPDATED' as COMP_RSLT 
    from ITEM as it
    inner join ITEM_HISTORY as ith on ith.ITEM_CODE = it.ITEM_CODE and it.USER_UPDATE_DATETIME <> ith.USER_UPDATE_DATETIME
)
select * from ad
union
select * from de
union
select * from up
order by
    CODE desc;
    
提出情報
提出日時2024/07/23 10:44:40
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者asano
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
84 MB
データパターン3
AC
84 MB