Código SQL [-] select a_codigo, sum(a_cantidad) from a where a_borrado=0 and a_codigo not in (select a_codigo from b where b_borrado=0) group by a_codigo union select a_codigo, sum (b_cantidad_real) from b where b_borrado=0 group by a_codigo
select a_codigo, sum(a_cantidad) from a where a_borrado=0 and a_codigo not in (select a_codigo from b where b_borrado=0) group by a_codigo union select a_codigo, sum (b_cantidad_real) from b where b_borrado=0 group by a_codigo