ソースコード
with
    now as (
        select
            i.item_code as i_code
            ,i.item_name as i_item_name
            ,i.user_update_datetime as i_user_update_datetime
            ,ih.item_code as ih_code
            ,ih.user_update_datetime as ih_user_update_datetime
        from
            item i
        left join
            item_history ih
        on
            i.item_code = ih.item_code
    )
    ,past as (
        select
            ih.item_code as ih_code
            ,ih.item_name as ih_item_name
            ,ih.user_update_datetime as ih_user_update_datetime
            ,i.item_code as i_code
            ,i.user_update_datetime as i_user_update_datetime
        from
            item_history ih
        left join
            item i
        on
            ih.item_code = i.item_code
    )
    ,u as (
        select
            i_code as code
            ,i_item_name as name
            ,'UPDATED' as comp_rslt
        from
            now
        where
            i_user_update_datetime != ih_user_update_datetime
    )
    ,a as (
        select
            i_code as code
            ,i_item_name as name
            ,'ADDED' as comp_rslt
        from
            now
        where
            ih_code is null
    )
    ,d as (
        select
            ih_code as code
            ,ih_item_name as name
            ,'DELETED' as comp_rslt
        from
            past
        where
            i_code is null
    )
    ,uni as (
        select
            *
        from
            u
        union
        select
            *
        from
            a
        union
        select
            *
        from
            d
    )

select
    code as CODE
    ,name as NAME
    ,comp_rslt as COMP_RSLT
from
    uni
order by
    1 desc
提出情報
提出日時2024/04/19 14:40:18
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者takahirostone
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量88 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
82 MB
データパターン2
AC
88 MB
データパターン3
AC
83 MB