查找,删除重复数据

群: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;

你可能感兴趣的:(table,insert,by,having,count,create,group,from,into)