Oracle面试题 删除重复的数据并且保留最大的id

来源:互联网 发布:战网客户端mac版下载 编辑:程序博客网 时间:2024/06/15 09:58

在执行代码前


在执行此代码后

delete  from student where  ROWID not in 
(
   select Max(rowid) from student 
   GROUP  by stuname,stuage 
   HAVING (count(*)=1)


   UNION


   select Max(rowid) from student 
   GROUP by stuname,stuage
   HAVING (count(*)>1)
);


阅读全文
0 0
原创粉丝点击