I have a table, where it has status like active, terminated.
I have checked the duplicate records in the table with PNID how many active and how many terminated are there.. I found only one record.
select PNID, count(*) from ActiveStatus group by PNID HAVING count(*) > 1; -- I found only one PNID which has active and terminated record.
But when I search with PNUI
select PNUI, count(*) from ActiveStatus group by PNUI HAVING count(*) > 1; -- I found a lot
I took one id and search the data .. looks like
PNID PNUI status
68765 01844 Active
10002 01844 terminate
11189 01844 terminate
19189 01844 Active
delete from ActiveStatus
where staus in ('Terminate') and PNID in (select PNUI
group by PNUI) having count(*)>1
Is this query correct to delete records?