ソースコード
WITH STOCK_MANAGEMENT_TARGET_ITEM AS (
    SELECT ITEM_CODE AS CODE
    FROM ITEM
    WHERE STOCK_MANAGEMENT_TYPE = 1
),

ITEM_LAST_DELIVERY_DATE AS (
    SELECT ITEM_CODE AS CODE,
          MAX(LAST_DELIVERY_DATE) AS LDD
    FROM STOCK
    GROUP BY ITEM_CODE
)
DELETE FROM ITEM
WHERE 
  ITEM_CODE IN (SELECT CODE FROM STOCK_MANAGEMENT_TARGET_ITEM)
  AND  
     (ITEM_CODE NOT IN (SELECT DISTINCT ITEM_CODE FROM STOCK)
  OR ITEM_CODE     IN (SELECT          ITEM_CODE FROM STOCK 
                                                  WHERE ITEM_CODE IN (
                                                                      SELECT ITEM_CODE 
                                                                      FROM STOCK
                                                                      JOIN ITEM_LAST_DELIVERY_DATE
                                                                      ON STOCK.ITEM_CODE = ITEM_LAST_DELIVERY_DATE.CODE
                                                                      WHERE LDD <= '2022-12-01'
                                                                      )
                                                    AND ACTUAL_AMT = 0
                        )
    )
提出情報
提出日時2023/06/19 11:17:08
コンテスト第7回 SQLコンテスト
問題商品整理
受験者bo-bobo
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量96 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
96 MB
データパターン2
WA
96 MB