ソースコード
with update_new as
  (
    select
      a.ITEM_CODE as CODE,
      a.ITEM_NAME as NAME,
      case when b.ITEM_CODE is null then 'ADDED'
           when a.USER_UPDATE_DATETIME = b.USER_UPDATE_DATETIME then 'nomal'
           when a.USER_UPDATE_DATETIME <> b.USER_UPDATE_DATETIME then 'UPDATED'
           end as COMP_RSLT
    from
      ITEM as a
    left join
      ITEM_HISTORY as b
    on
      a.ITEM_CODE = b.ITEM_CODE
  ),
delet as
  (
    select
      a.ITEM_CODE as CODE,
      a.ITEM_NAME as NAME,
      case when b.ITEM_CODE is null then 'DELETED'
           else 'other'
        end as COMP_RSLT
    from
      ITEM_HISTORY as a
    left join
      ITEM as b
    on
      a.ITEM_CODE = b.ITEM_CODE
  )
select
  *
from
  update_new
where
  COMP_RSLT in ('ADDED', 'UPDATED')
union all
select
  *
from
  delet
where
  COMP_RSLT = 'DELETED'
order by
CODE desc
提出情報
提出日時2024/04/20 20:40:27
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者shikanai1993
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
84 MB
データパターン3
AC
84 MB