Ver originalupdate tabla set id_1 = (select (t1.id_1-SUM(t2.id_2)), t1.productofrom tabla2 t2, tabla1 t1where t1.producto=t2.productogroup by t1.producto)where EXIST(select t1.id_1, t2.productofrom tabla1);