MySQL Forums
Forum List  »  Spanish

Sumas no cuadran
Posted by: Jorge Gallardo Rius
Date: April 15, 2022 08:08AM

Estoy usando version 8 de MySQL. Tengo 3 tablas anuales (2017, 2018, 2019) con indices. Estoy creando una tabla de resumen, sumando los indicadores de cada tabla individual. Uso esta instrucción:

update sin_2017_2019 as table1, ind_sin_2017 as table2, ind_sin_2018 as table3, ind_sin_2019 as table4
set table1.DIAS = table2.DIAS + table3.DIAS + table4.DIAS
where table1.CIIU4 = table2.CIIU4 and table1.CIIU4 = table3.CIIU4 and table1.CIIU4 = table4.CIIU4;

La primera tabla es la tabla de resumen, mientras que las otras 3 tablas corresponden a 2017, 2018, 2019.

En algunos casos, hace la suma de los 3 indicadores anuales (cantidad de DIAS) correctamente y actualiza la table1 de resumen, pero en otros casos pareciera no encontrar el valor en las tablas anuales y carga un valor nulo. Raro porque el campo DIAS tiene DEFAULT 0 desde su creación. ¿Que podria estar afectando para que esto ocurra?

Options: ReplyQuote


Subject
Views
Written By
Posted
Sumas no cuadran
302
April 15, 2022 08:08AM
191
April 15, 2022 12:50PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.