欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

查找,删除重复数据

程序员文章站 2022-04-01 11:59:01
...
群:127881306
1 创建表A
create table a(
a int
);
2 创建表B
create table b(
b int
);
--select * into b from a ;
insert into b(b) select  a from a where a.a = 2;
3 插入数据 ,多插入几条重复的数据
insert into a values(1);
insert into a values(2);
insert into a values(3);
insert into a values(4);
4 --查询某表中重复的条数
select a,count(*) from A group by a having count(*)>1;

5--删除重复行数,只剩不重复的记录
delete from a le where le.rowid not in
       (select MAX(la.rowid) from a la group by la.a);
6 删掉表
drop table a;