With temp As ( Select ROW_NUMBER() over(partition by LogisticsPlan order by createon) rowID,ID from LogisticsPlan Where LogisticsPlan IN( 'AGDPM15071704', 'AGDDE15071401', 'SGDPM15071404', 'AGDPM15071404', 'SGDDE15071104' ) ) Delete from LogisticsPla…