-- EXEC MIG_ITEM_ONLY_1_Sp
CREATE OR ALTER PROCEDURE MIG_ITEM_ONLY_1_Sp
AS
BEGIN
	DELETE FROM MIG_ITEM_ONLY_1

	INSERT INTO MIG_ITEM_ONLY_1
	(
		[ITEM_KEY],
		[ZZ_ID_MAX]
	)
	SELECT DISTINCT 
		 STM.ITEM_KEY
		,MAX(STM.ZZ_ID) AS "ZZ_ID_MAX" 
	FROM ITEM STM 
	WHERE STM.OBJECT_TYPE = '0'
	GROUP BY STM.ITEM_KEY

END
