SQL去重复数据

CREATE TABLE xhftest
 (
 id int NOT NULL ,
 name varchar(50) NULL,
 sex char(1) NULL,
 age int NULL
 ) 

insert into xhftest (id,name,sex,age) values(1,'xhf',1,20)
insert into xhftest (id,name,sex,age) values(2,'xhf',1,30)
insert into xhftest (id,name,sex,age) values(3,'xhf1',1,30)
insert into xhftest (id,name,sex,age) values(4,'xhf1',1,30)
insert into xhftest (id,name,sex,age) values(5,'xhf2',1,30)
insert into xhftest (id,name,sex,age) values(6,'xhf2',1,30)
insert into xhftest (id,name,sex,age) values(7,'xhf2',1,30)
insert into xhftest (id,name,sex,age) values(8,'xhf3',1,30)
insert into xhftest (id,name,sex,age) values(9,'xhf3',1,30)
insert into xhftest (id,name,sex,age) values(10,'xhf3',1,30)
insert into xhftest (id,name,sex,age) values(11,'xhf4',1,30)
insert into xhftest (id,name,sex,age) values(12,'xhf5',1,25)

select * from xhftest

select name,sex,age from xhftest group by name,sex,age having count(*)>=2

select a.* from xhftest a,(select name,sex,age from xhftest group by name,sex,age having count(*)>=2) b
where a.name=b.name and a.sex=b.sex and a.age=b.age


drop table xhftest

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值