oracle 选择重复记录,oracle 重复记录

表:-- Create table

create table LOCATION

(

LOC            NVARCHAR2(15) not null,

DESCRIPTION    NVARCHAR2(40),

USERID         NVARCHAR2(20),

CREATEBY       VARCHAR2(30),

CREATETIME     DATE,

MODIFYBY       VARCHAR2(30),

LASTMODIFYTIME DATE,

STOREAREA_CODE VARCHAR2(4),

STOREKEEPER    VARCHAR2(20)

)

一。查找重复记录

1。查找全部重复记录

Select * From location l Where l.storekeeper In (Select l.storekeeper From location Group By l.storekeeper Having Count(*)>1)

2。过滤重复记录(只显示一条)

Select * From location l Where rowid In (Select Max(rowid) From location l Group By l.storekeeper)

二。删除重复记录

1。删除全部重复记录(慎用)

Delete location l Where l.storekeeper In (Select l.storekeeper From location l Group By l.storekeeper Having Count(*)>1)

2。保留一条

Delete location Where rownum Not In (Select Max(rownum) From location l Group By l.storekeeper)

(原创)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值