delete from wf_tbl_name where workitemstate=4 and isarchive=0 and
rowid not in (
select max(tt.rowid) from wf_tbl_name tt where tt.workitemstate=4
and tt.isarchive=0 group by tt.workitemindex,tt.processinstanceid);
delete from wf_tbl_name where workitemstate=4 and isarchive=0 and
rowid not in (
select max(tt.rowid) from wf_tbl_name tt where tt.workitemstate=4
and tt.isarchive=0 group by tt.workitemindex,tt.processinstanceid);