-- passe sur mysql
update ACH a, FLU f1, FLU f2
set a.ACH_FLU_FK = f2.flu_id
where
f1.flu_id = a.ACH_FLU_FK and
f1.padt = f2.padt and
f1.contrat = f2.contrat and
f1.code_flux = f2.code_flux
and (f1.padt, f1.contrat, f1.code_flux) in
( select padt,contrat,code_flux from FLU group by padt,contrat,code_flux having count(*)>1 )
and f2.flu_id in ( select min(flu_id) from FLU group by padt,contrat,code_flux having count(*)>1 )
and f1.flu_id<>f2.flu_id ;
-- devrait passer sur oracle
delete from FLU f3 where f3.flu_id in (
select f1.flu_id
from FLU f1, FLU f2
where
f1.padt = f2.padt and
f1.contrat = f2.contrat and
f1.code_flux = f2.code_flux
and (f1.padt, f1.contrat, f1.code_flux) in
( select padt,contrat,code_flux from FLU group by padt,contrat,code_flux having count(*)>1 )
and f2.flu_id in ( select min(flu_id) from FLU group by padt,contrat,code_flux having count(*)>1 )
and f1.flu_id<>f2.flu_id ) ;
[^] # Re: .
Posté par snt . En réponse au message SQL : Requête d'update pas triviale.. Évalué à 3.
update ACH a, FLU f1, FLU f2
set a.ACH_FLU_FK = f2.flu_id
where
f1.flu_id = a.ACH_FLU_FK and
f1.padt = f2.padt and
f1.contrat = f2.contrat and
f1.code_flux = f2.code_flux
and (f1.padt, f1.contrat, f1.code_flux) in
( select padt,contrat,code_flux from FLU group by padt,contrat,code_flux having count(*)>1 )
and f2.flu_id in ( select min(flu_id) from FLU group by padt,contrat,code_flux having count(*)>1 )
and f1.flu_id<>f2.flu_id ;
-- devrait passer sur oracle
delete from FLU f3 where f3.flu_id in (
select f1.flu_id
from FLU f1, FLU f2
where
f1.padt = f2.padt and
f1.contrat = f2.contrat and
f1.code_flux = f2.code_flux
and (f1.padt, f1.contrat, f1.code_flux) in
( select padt,contrat,code_flux from FLU group by padt,contrat,code_flux having count(*)>1 )
and f2.flu_id in ( select min(flu_id) from FLU group by padt,contrat,code_flux having count(*)>1 )
and f1.flu_id<>f2.flu_id ) ;