delete from Raport_Blad_wp_d where id_zamowienie in
(
select id_zamowienie from
(
select x.id_zamowienie, x.status, count(*) as cnt from Raport_Blad_wp_d x
--where id_zamowienie = 300340659
group by
x.id_zamowienie,
x.status
) as t
group by id_zamowienie having count(t.id_zamowienie)=1
)