ソースコード
WITH TEMP AS (
  WITH TGT AS (
    SELECT
      DISTINCT ITEM_CODE
    FROM
      ITEM
    UNION
    SELECT
      DISTINCT ITEM_CODE
    FROM
      ITEM_HISTORY
  )
  SELECT
    TGT.ITEM_CODE AS ITEM_CODE,
    ITEM.ITEM_CODE AS NEW,
    ITEM_HISTORY.ITEM_CODE AS OLD,
    ITEM.USER_UPDATE_DATETIME <> ITEM_HISTORY.USER_UPDATE_DATETIME AS UPD,
    COALESCE(ITEM.ITEM_NAME, ITEM_HISTORY.ITEM_NAME) AS ITEM_NAME,
    *
  FROM
    TGT
    LEFT JOIN ITEM USING(ITEM_CODE)
    LEFT JOIN ITEM_HISTORY USING(ITEM_CODE)
)
SELECT
  ITEM_CODE AS CODE,
  ITEM_NAME AS NAME,
  'ADDED' AS COMP_RSLT
FROM
  TEMP
WHERE
  OLD IS NULL
UNION
SELECT
  ITEM_CODE AS CODE,
  ITEM_NAME AS NAME,
  'DELETED' AS COMP_RSLT
FROM
  TEMP
WHERE
  NEW IS NULL
UNION
SELECT
  ITEM_CODE AS CODE,
  ITEM_NAME AS NAME,
  'UPDATED' AS COMP_RSLT
FROM
  TEMP
WHERE
  UPD = 1
ORDER BY
  CODE DESC
提出情報
提出日時2024/04/19 13:52:56
コンテスト第12回 SQLコンテスト
問題データ操作履歴
受験者suse.leaf
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量94 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
82 MB
データパターン3
AC
94 MB