delete Patient
from Patient as aa
left join (
select min(id) as id from Patient
group by patientid
) as bb
on aa.id = bb.id
where bb.id is null
delete Patient
from Patient as aa
left join (
select min(id) as id from Patient
group by patientid
) as bb
on aa.id = bb.id
where bb.id is null