读书人

剔除除重复的数据并保留一行

发布时间: 2012-12-17 09:31:40 作者: rapoo

删除除重复的数据,并保留一行
表A

ID mobile

1 15195986888
2 15195986888
3 15195986888
4 13776667680
5 13776667680
6 13776667680
7 18196999999

现在要删除里面的重复数据 并保留一行
结果如下
1 15195986888
2 13776667680
3 18196999999


[最优解释]

delete from a where rowid not in (select max(rowid) from a group by mobile);

[其他解释]
看你要干啥,建议你建一个临时表插进去

insert into XXXX
SELECT max(id),mobile from A
group by mobile;
commit;

方便回溯。
[其他解释]
对,就是用max或min
[其他解释]
顶顶顶顶顶顶。。。
[其他解释]
distinct
[其他解释]
三楼正解!!

读书人网 >oracle

热点推荐