ソースコード
DELETE FROM ITEM
WHERE 
(
    ITEM_CODE IN (
        SELECT distinct(i.ITEM_CODE)
        FROM ITEM as i
            LEFT OUTER JOIN STOCK as s
            on i.ITEM_CODE = s.ITEM_CODE
        where s.ITEM_CODE is null 
    )
or
    ITEM_CODE IN (
        SELECT i.ITEM_CODE
        FROM ITEM as i
            INNER JOIN STOCK as s
            on i.ITEM_CODE = s.ITEM_CODE
            INNER JOIN (SELECT ITEM_CODE ,MAX(LAST_DELIVERY_DATE) as m_date FROM STOCK group by ITEM_CODE having m_date <= '2022-12-01') as s2
            on s2.ITEM_CODE = s.ITEM_CODE
        group by i.ITEM_CODE
        having SUM(ACTUAL_AMT) = 0
    )
)
and STOCK_MANAGEMENT_TYPE = '1'
;
-- SELECT * FROM ITEM;
提出情報
提出日時2023/06/19 00:49:07
コンテスト第7回 SQLコンテスト
問題商品整理
受験者Hodgepodge
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
79 MB
データパターン2
AC
78 MB