SQL去重复数据

ORACLE 专栏收录该内容
5 篇文章 0 订阅

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

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值