ソースコード
with update_table as (
select 
a.item_code as CODE,
a.item_name as NAME,
'UPDATED' as COMP_RSLT
from
item a
inner join item_history b
on a.item_code = b.item_code
where 
a.item_code = b.item_code
and a.user_update_datetime > b.user_update_datetime
)
,delete_table as (
select 
a.item_code as CODE,
a.item_name as NAME,
'DELETED' as COMP_RSLT
from
item_history a
left outer join item b
on a.item_code = b.item_code
where b.item_code is null

)
,add_table as (
select 
a.item_code as CODE,
a.item_name as NAME,
'ADDED' as COMP_RSLT
from
item a
left join item_history b
on a.item_code = b.item_code
where 
 b.item_code is null
)
select CODE, NAME, COMP_RSLT from update_table
union all
select CODE, NAME, COMP_RSLT from add_table
union all
select CODE, NAME, COMP_RSLT from delete_table
order by CODE desc
;
提出情報
提出日時2024/04/24 15:43:10
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者masashi_sql
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
82 MB
データパターン2
AC
86 MB
データパターン3
AC
82 MB