ソースコード
WITH maxdata AS (
SELECT
	ITEM_CODE
	,max(LAST_DELIVERY_DATE) AS Mdate
FROM STOCK AS t2
GROUP BY 1
)
,deldata AS (
SELECT
	t0.ITEM_CODE
	,t0.Mdate
	,t2.ACTUAL_AMT
FROM maxdata AS t0
INNER JOIN STOCK AS t2
	ON t0.ITEM_CODE = t2.ITEM_CODE
		AND t0.Mdate = t2.LAST_DELIVERY_DATE
WHERE t2.ACTUAL_AMT = 0
	AND Mdate <= '2022-12-01'
)
DELETE
FROM ITEM AS t0
WHERE STOCK_MANAGEMENT_TYPE = 1
	AND ( NOT EXISTS(
		SELECT 1
		FROM STOCK AS t1
		WHERE t0.ITEM_CODE = t1.ITEM_CODE
		)
	OR EXISTS(
		SELECT 1
		FROM deldata AS t2
		WHERE t0.ITEM_CODE = t2.ITEM_CODE
		)
	)
提出情報
提出日時2023/06/18 23:25:28
コンテスト第7回 SQLコンテスト
問題商品整理
受験者katsu
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
78 MB
データパターン2
WA
86 MB