ソースコード
WITH UPDATED AS ( 
  SELECT
    I.ITEM_CODE AS CODE
    , I.ITEM_NAME AS NAME
    , 'UPDATED' AS COMP_RSLT 
  FROM
    ITEM AS I 
    INNER JOIN ITEM_HISTORY AS IH 
      ON I.ITEM_CODE = IH.ITEM_CODE 
      AND I.USER_UPDATE_DATETIME != IH.USER_UPDATE_DATETIME 
  ORDER BY
    CODE
) 
, ADDED AS ( 
  SELECT
    I.ITEM_CODE AS CODE
    , I.ITEM_NAME AS NAME
    , 'ADDED' AS COMP_RSLT 
  FROM
    ITEM AS I 
    LEFT OUTER JOIN ITEM_HISTORY AS IH 
      ON I.ITEM_CODE = IH.ITEM_CODE 
  WHERE
    IH.ITEM_CODE IS NULL 
  ORDER BY
    CODE
) 
, DELETED AS ( 
  SELECT
    IH.ITEM_CODE AS CODE
    , IH.ITEM_NAME AS NAME
    , 'DELETED' AS COMP_RSLT 
  FROM
    ITEM AS I 
    RIGHT OUTER JOIN ITEM_HISTORY AS IH 
      ON I.ITEM_CODE = IH.ITEM_CODE 
  WHERE
    I.ITEM_CODE IS NULL 
  ORDER BY
    CODE
) 
SELECT
  * 
FROM
  UPDATED 
UNION ALL 
SELECT
  * 
FROM
  ADDED 
UNION ALL 
SELECT
  * 
FROM
  DELETED 
ORDER BY
  CODE DESC;
提出情報
提出日時2024/04/19 13:26:35
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者nagata
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量92 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
AC
92 MB
データパターン3
AC
86 MB