oracle保留30天的数据删除,oracle 查询重复数据并且删除, 只保留一条数据的SQL语句...

delete from t_account where feedate in (

select feedate

from t_account

group by feedate

having count(1)>1

) and id not in (

select min(id)

from t_account

group by feedate

having count(1)>1

)

------------------------------------------------

delete from (

select * from t_account

where id not in(select min(id) from t_account group by feedate)

) t;

--------------------------------------------------

delete from t_account

where id in (select id

from t_account

where feedate in (select feedate

from t_account

group by feedate

having count(*) > 1)

minus

select min(id)

from t_account

where feedate in (select feedate

from t_account

group by feedate

having count(*) > 1)

group by feedate)

---------------------------------------------------

delete from t_account where id in

(

select id from

(

select rank() over(order by feedate) r ,ac.* from t_account ac

minus

select row_number() over(order by feedate) r, ac.* from t_account ac

)

);

----------------------------------------------------

delete  from t_account top

where

to_char(top.feedate)in(

select up1.up1date from

(select to_char(feedate) up1date,count(id) up1num from t_account  group by(to_char(feedate)) ) up1

where up1.up1num>1

)

and

top.id not in(

select min(tac.id) up3id from (

select up1.up1date up2date from

(select to_char(feedate) up1date,count(id) up1num from t_account  group by(to_char(feedate)) ) up1

where up1.up1num>1

)up2 left join t_account tac on up2.up2date=to_char(tac.feedate) group by to_char(tac.feedate)

)

-----------------------------------------------------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值