sql语句总结【重复数据修改调整】

(1)valid置为0

update online_bra_off_rec_sub_bra a
set valid=0
where id in ((
select id from online_bra_off_rec_sub_bra 
where sub_branch_org_code =a.sub_branch_org_code
) minus (select min(id)  from online_bra_off_rec_sub_bra 
where sub_branch_org_code =a.sub_branch_org_code))
and a.sub_branch_org_code in (
'5505',
'40DH',
'40DI',
'48D4',
'1100',
'7907',
'2605',
'E700',
'01J0')
(2)线上推广码、线下推广码反转
将线下推广码赋给ext1,然后将线上推广码赋给线下推广码,把ext1赋给线上推广码,把ext1置为null
1.将线下推广码赋给ext1
update online_bra_off_rec_sub_bra a
set 
ext1=(

select OffLINE_PROMOTION_CODE

from online_bra_off_rec_sub_bra b 

where a.sub_branch_org_code=b.sub_branch_org_code )

where 
a.sub_branch_org_code in (

'A3D4',
'A3DF',
'A3D1',
'A3DB',
'A3DI',
'A3DA') 
2.然后将线上推广码赋给线下推广码
update online_bra_off_rec_sub_bra a
set 
OffLINE_PROMOTION_CODE=(

select OnLINE_PROMOTION_CODE

from online_bra_off_rec_sub_bra b 

 where a.sub_branch_org_code=b.sub_branch_org_code )

where 
a.sub_branch_org_code in (
'A3DI',
'A3DA') 
3.把ext1赋给线上推广码
update online_bra_off_rec_sub_bra a
set 
OnLINE_PROMOTION_CODE=(

select ext1 

from online_bra_off_rec_sub_bra b 

where a.sub_branch_org_code=b.sub_branch_org_code )

where 
a.sub_branch_org_code in (
'A3D4',
'A3DF',
'A3DI',
'A3DA') 
4.把ext1置为null
update online_bra_off_rec_sub_bra a
set 
ext1=null
where 
a.sub_branch_org_code in (

'A3DI',
'A3DA') 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值