Question : deletion


I have a table x . Please see the image attached below for the data

This table donot have any primary key. I want to delete the records in the table which has duplicate prospectcaseid for the same client. Please suggest how I can do this

Attachments:

Answer : deletion

Looks OK to me.

If there are indexes on the table I might duplicate the where clause internally so I'm not selecting the max(rowid) from the entire table but it should work without it.

delete from tab1 where rowid not in (
select max(rowid) from tab1
where clientid=2 and clientname='b' and prospectcaseid=2
group by clientid, prospectcaseid,clientname
)
and clientid=2
and clientname='b'
and prospectcaseid=2  ;
Random Solutions  
 
programming4us programming4us