Declare
Begin
For r In ( Select t.医嘱id, t.操作类型, t.操作时间, t.操作员id
From 个人医嘱操作20190222 t

Group By t.医嘱id, t.操作类型, t.操作时间, t.操作员id
Having Count(*) > 1 ) Loop
Delete From 个人医嘱操作 t
Where (t.医嘱id, t.操作类型, t.操作时间, t.操作员id) In
(Select t.医嘱id, t.操作类型, t.操作时间, t.操作员id
From 个人医嘱操作 t
Where t.医嘱id = r.医嘱id
Group By t.医嘱id, t.操作类型, t.操作时间, t.操作员id
Having Count(*) > 1)
And Rowid Not In (Select Min(Rowid)
From 个人医嘱操作 t
Where t.医嘱id = r.医嘱id
Group By t.医嘱id, t.操作类型, t.操作时间, t.操作员id
Having Count(*) > 1);
End Loop;
End;