删除重复记录的高效SQL

删除重复记录的高效SQL:

delete from student pdi where pdi.rowid in
(select t1.rowid FROM student t1,
   (select t.s_no, max(t.id) max_id from student t group by t.s_no having count(*) > 1) t2
where t1.s_no = t2.s_no and t1.id != t2.max_id)

你可能感兴趣的:(sql)