Just specify each color and delete everything where the number is greater than 1:
;with cte as(select t1.*, row_number() over(partition by t1.color
order by(select null)) as rn
from table1 t1
join table2 t2 on t1.color = t2.color)
delete from cte where rn > 1
Or change to:
delete from cte where rn = 1
if you want to remove only one row for each color.
source
share