Delete Has_Tested Where stu_uid Not In (Select Max(id) as newsid From Has_Tested Group By stu_uid order by newsid)