Dopo ore di duro lavoro sono riuscito a trovare un sistema ottimale:
codice:
update
tbl_tmp_conversion c ,
(select tc.idKeyModel,
tc.Curr,
sum(tc.Sep_StdY) as TarReference,
sum(tc.Jan_CY) as TarActual
from kmsexport.tbl_tmp_conversion c,
kmsexport.tbl_causalscategories cc,
tbl_kmstargetcosts tc
where tc.RowType = 'D' and
tc.Conditions = 'TARGET 2011' and
tc.Plant = 'All Plants' and
tc.CostType = 'TVMC' and
tc.idKeyModel = c.IdKeyModel and
tc.Year = '2011' and
cc.IDCausalCategory = tc.IdCasual
group by tc.idKeyModel) as i
set c.CurrTarget = i.Curr,
c.TarReference = i.TarReference,
c.TarActual = i.TarActual
where c.idKeyModel =i.idKeyModel;
RISOLTO!